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/pom.xml b/asterix-app/pom.xml
index 686bdb0..df9a0e5 100644
--- a/asterix-app/pom.xml
+++ b/asterix-app/pom.xml
@@ -131,13 +131,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.asterix</groupId>
-            <artifactId>asterix-aql</artifactId>
-            <version>0.8.8-SNAPSHOT</version>
-            <type>jar</type>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.asterix</groupId>
             <artifactId>asterix-om</artifactId>
             <version>0.8.8-SNAPSHOT</version>
             <type>jar</type>
@@ -224,5 +217,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-
 </project>
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
index 3a33bbe..9cdaf31 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
@@ -24,11 +24,6 @@
 import java.util.List;
 
 import org.apache.asterix.api.common.Job.SubmissionMode;
-import org.apache.asterix.aql.base.Statement.Kind;
-import org.apache.asterix.aql.expression.FunctionDecl;
-import org.apache.asterix.aql.expression.Query;
-import org.apache.asterix.aql.expression.visitor.AQLPrintVisitor;
-import org.apache.asterix.aql.rewrites.AqlRewriter;
 import org.apache.asterix.common.config.AsterixCompilerProperties;
 import org.apache.asterix.common.config.AsterixExternalProperties;
 import org.apache.asterix.common.config.OptimizationConfUtil;
@@ -40,6 +35,11 @@
 import org.apache.asterix.dataflow.data.common.AqlPartialAggregationTypeComputer;
 import org.apache.asterix.formats.base.IDataFormat;
 import org.apache.asterix.jobgen.AqlLogicalExpressionJobGen;
+import org.apache.asterix.lang.aql.rewrites.AqlRewriter;
+import org.apache.asterix.lang.aql.visitor.AQLPrintVisitor;
+import org.apache.asterix.lang.common.base.Statement.Kind;
+import org.apache.asterix.lang.common.statement.FunctionDecl;
+import org.apache.asterix.lang.common.statement.Query;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.declared.AqlMetadataProvider;
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/common/FeedWorkCollection.java b/asterix-app/src/main/java/org/apache/asterix/api/common/FeedWorkCollection.java
index 063f30e..f25c5dd 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/common/FeedWorkCollection.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/common/FeedWorkCollection.java
@@ -25,16 +25,16 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.expression.DataverseDecl;
-import org.apache.asterix.aql.expression.Identifier;
-import org.apache.asterix.aql.expression.SubscribeFeedStatement;
 import org.apache.asterix.aql.translator.AqlTranslator;
 import org.apache.asterix.common.feeds.FeedConnectionRequest;
 import org.apache.asterix.common.feeds.FeedConnectionRequest.ConnectionStatus;
 import org.apache.asterix.common.feeds.api.IFeedWork;
 import org.apache.asterix.common.feeds.api.IFeedWorkEventListener;
 import org.apache.asterix.feeds.FeedCollectInfo;
+import org.apache.asterix.lang.aql.statement.SubscribeFeedStatement;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.statement.DataverseDecl;
+import org.apache.asterix.lang.common.struct.Identifier;
 import org.apache.asterix.om.util.AsterixAppContextInfo;
 import org.apache.hyracks.api.job.JobId;
 
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java
index 99706ed..c22cb8e 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java
@@ -37,12 +37,12 @@
 import org.apache.asterix.api.common.APIFramework;
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.parser.AQLParser;
-import org.apache.asterix.aql.parser.ParseException;
-import org.apache.asterix.aql.parser.TokenMgrError;
 import org.apache.asterix.aql.translator.AqlTranslator;
 import org.apache.asterix.common.config.GlobalConfig;
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.aql.parser.AQLParser;
+import org.apache.asterix.lang.aql.parser.TokenMgrError;
+import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.result.ResultReader;
 import org.apache.asterix.result.ResultUtils;
@@ -116,7 +116,7 @@
             duration = (endTime - startTime) / 1000.00;
             out.println(APIFramework.HTML_STATEMENT_SEPARATOR);
             out.println("<PRE>Duration of all jobs: " + duration + " sec</PRE>");
-        } catch (ParseException | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError pe) {
+        } catch (AsterixException | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError pe) {
             GlobalConfig.ASTERIX_LOGGER.log(Level.INFO, pe.toString(), pe);
             ResultUtils.webUIParseExceptionHandler(out, pe, query);
         } catch (Exception e) {
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/AQLAPIServlet.java b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/AQLAPIServlet.java
index 50b1e95..9a9b345 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/AQLAPIServlet.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/AQLAPIServlet.java
@@ -23,7 +23,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.asterix.aql.base.Statement.Kind;
+import org.apache.asterix.lang.common.base.Statement.Kind;
 
 public class AQLAPIServlet extends RESTAPIServlet {
 
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/DDLAPIServlet.java b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/DDLAPIServlet.java
index 4e517a3..65760a0d 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/DDLAPIServlet.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/DDLAPIServlet.java
@@ -23,8 +23,8 @@
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.base.Statement.Kind;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.base.Statement.Kind;
 
 public class DDLAPIServlet extends RESTAPIServlet {
     private static final long serialVersionUID = 1L;
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryAPIServlet.java b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryAPIServlet.java
index 470772a..9f7657d 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryAPIServlet.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryAPIServlet.java
@@ -23,8 +23,8 @@
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.base.Statement.Kind;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.base.Statement.Kind;
 
 public class QueryAPIServlet extends RESTAPIServlet {
     private static final long serialVersionUID = 1L;
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/RESTAPIServlet.java b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/RESTAPIServlet.java
index e13ac8e..be17229 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/RESTAPIServlet.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/RESTAPIServlet.java
@@ -30,25 +30,24 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.io.IOUtils;
-import org.json.JSONObject;
-
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.base.Statement.Kind;
-import org.apache.asterix.aql.parser.AQLParser;
-import org.apache.asterix.aql.parser.ParseException;
-import org.apache.asterix.aql.parser.TokenMgrError;
 import org.apache.asterix.aql.translator.AqlTranslator;
 import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.aql.parser.AQLParser;
+import org.apache.asterix.lang.aql.parser.TokenMgrError;
+import org.apache.asterix.lang.aql.util.AQLFormatPrintUtil;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.base.Statement.Kind;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.result.ResultReader;
 import org.apache.asterix.result.ResultUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
 import org.apache.hyracks.api.dataset.IHyracksDataset;
 import org.apache.hyracks.client.dataset.HyracksDataset;
+import org.json.JSONObject;
 
 abstract class RESTAPIServlet extends HttpServlet {
     private static final long serialVersionUID = 1L;
@@ -62,8 +61,7 @@
      * SessionConfig with the appropriate output writer and output-format
      * based on the Accept: header and other servlet parameters.
      */
-    static SessionConfig initResponse(HttpServletRequest request, HttpServletResponse response)
-        throws IOException {
+    static SessionConfig initResponse(HttpServletRequest request, HttpServletResponse response) throws IOException {
         response.setCharacterEncoding("utf-8");
 
         // CLEAN_JSON output is the default; most generally useful for a
@@ -76,12 +74,10 @@
         if (output != null) {
             if (output.equals("CSV")) {
                 format = OutputFormat.CSV;
-            }
-            else if (output.equals("ADM")) {
+            } else if (output.equals("ADM")) {
                 format = OutputFormat.ADM;
             }
-        }
-        else {
+        } else {
             // Second check the Accept: HTTP header.
             if (accept != null) {
                 if (accept.contains("application/x-adm")) {
@@ -93,9 +89,9 @@
         }
 
         // If it's JSON, check for the "lossless" flag
-        if (format == OutputFormat.CLEAN_JSON &&
-                ("true".equals(request.getParameter("lossless")) ||
-                (accept != null && accept.contains("lossless=true")))) {
+        if (format == OutputFormat.CLEAN_JSON
+                && ("true".equals(request.getParameter("lossless")) || (accept != null && accept
+                        .contains("lossless=true")))) {
             format = OutputFormat.LOSSLESS_JSON;
         }
 
@@ -113,12 +109,11 @@
                 break;
             case CSV: {
                 // Check for header parameter or in Accept:.
-                if ("present".equals(request.getParameter("header")) ||
-                    (accept != null && accept.contains("header=present"))) {
+                if ("present".equals(request.getParameter("header"))
+                        || (accept != null && accept.contains("header=present"))) {
                     response.setContentType("text/csv; header=present");
                     sessionConfig.set(SessionConfig.FORMAT_CSV_HEADER, true);
-                }
-                else {
+                } else {
                     response.setContentType("text/csv; header=absent");
                 }
             }
@@ -168,7 +163,7 @@
                 AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, sessionConfig);
                 aqlTranslator.compileAndExecute(hcc, hds, resultDelivery);
             }
-        } catch (ParseException | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError pe) {
+        } catch (AsterixException | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError pe) {
             GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, pe.getMessage(), pe);
             String errorMessage = ResultUtils.buildParseExceptionMessage(pe, query);
             JSONObject errorResp = ResultUtils.getErrorResponse(2, errorMessage, "", "");
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java
index b436061..d08134f 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java
@@ -23,8 +23,8 @@
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.base.Statement.Kind;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.base.Statement.Kind;
 
 public class UpdateAPIServlet extends RESTAPIServlet {
     private static final long serialVersionUID = 1L;
diff --git a/asterix-app/src/main/java/org/apache/asterix/api/java/AsterixJavaClient.java b/asterix-app/src/main/java/org/apache/asterix/api/java/AsterixJavaClient.java
index 3276a60..a9b012d 100644
--- a/asterix-app/src/main/java/org/apache/asterix/api/java/AsterixJavaClient.java
+++ b/asterix-app/src/main/java/org/apache/asterix/api/java/AsterixJavaClient.java
@@ -26,11 +26,9 @@
 import org.apache.asterix.api.common.Job;
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.parser.AQLParser;
-import org.apache.asterix.aql.parser.ParseException;
 import org.apache.asterix.aql.translator.AqlTranslator;
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.aql.parser.AQLParser;
+import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
 import org.apache.hyracks.api.job.JobSpecification;
@@ -59,7 +57,7 @@
 
     public void compile(boolean optimize, boolean printRewrittenExpressions, boolean printLogicalPlan,
             boolean printOptimizedPlan, boolean printPhysicalOpsOnly, boolean generateBinaryRuntime, boolean printJob)
-            throws Exception {
+                    throws Exception {
         queryJobSpec = null;
         dmlJobs = null;
 
@@ -72,17 +70,11 @@
             builder.append((char) ch);
         }
         AQLParser parser = new AQLParser(builder.toString());
-        List<Statement> aqlStatements;
-        try {
-            aqlStatements = parser.parse();
-        } catch (ParseException pe) {
-            throw new AsterixException(pe);
-        }
+        List<Statement> aqlStatements = parser.parse();
         MetadataManager.INSTANCE.init();
 
         SessionConfig conf = new SessionConfig(writer, OutputFormat.ADM, optimize, true, generateBinaryRuntime);
-        conf.setOOBData(false, printRewrittenExpressions, printLogicalPlan,
-                        printOptimizedPlan, printJob);
+        conf.setOOBData(false, printRewrittenExpressions, printLogicalPlan, printOptimizedPlan, printJob);
         if (printPhysicalOpsOnly) {
             conf.set(SessionConfig.FORMAT_ONLY_PHYSICAL_OPS, true);
         }
diff --git a/asterix-app/src/main/java/org/apache/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/org/apache/asterix/aql/translator/AqlTranslator.java
index dcfbc98..8029e0d 100644
--- a/asterix-app/src/main/java/org/apache/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/org/apache/asterix/aql/translator/AqlTranslator.java
@@ -43,50 +43,10 @@
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
-
 import org.apache.asterix.api.common.APIFramework;
 import org.apache.asterix.api.common.Job;
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.expression.CompactStatement;
-import org.apache.asterix.aql.expression.ConnectFeedStatement;
-import org.apache.asterix.aql.expression.CreateDataverseStatement;
-import org.apache.asterix.aql.expression.CreateFeedPolicyStatement;
-import org.apache.asterix.aql.expression.CreateFeedStatement;
-import org.apache.asterix.aql.expression.CreateFunctionStatement;
-import org.apache.asterix.aql.expression.CreateIndexStatement;
-import org.apache.asterix.aql.expression.CreatePrimaryFeedStatement;
-import org.apache.asterix.aql.expression.CreateSecondaryFeedStatement;
-import org.apache.asterix.aql.expression.DatasetDecl;
-import org.apache.asterix.aql.expression.DataverseDecl;
-import org.apache.asterix.aql.expression.DataverseDropStatement;
-import org.apache.asterix.aql.expression.DeleteStatement;
-import org.apache.asterix.aql.expression.DisconnectFeedStatement;
-import org.apache.asterix.aql.expression.DropStatement;
-import org.apache.asterix.aql.expression.ExternalDetailsDecl;
-import org.apache.asterix.aql.expression.FeedDropStatement;
-import org.apache.asterix.aql.expression.FeedPolicyDropStatement;
-import org.apache.asterix.aql.expression.FunctionDecl;
-import org.apache.asterix.aql.expression.FunctionDropStatement;
-import org.apache.asterix.aql.expression.IDatasetDetailsDecl;
-import org.apache.asterix.aql.expression.Identifier;
-import org.apache.asterix.aql.expression.IndexDropStatement;
-import org.apache.asterix.aql.expression.InsertStatement;
-import org.apache.asterix.aql.expression.InternalDetailsDecl;
-import org.apache.asterix.aql.expression.LoadStatement;
-import org.apache.asterix.aql.expression.NodeGroupDropStatement;
-import org.apache.asterix.aql.expression.NodegroupDecl;
-import org.apache.asterix.aql.expression.Query;
-import org.apache.asterix.aql.expression.RefreshExternalDatasetStatement;
-import org.apache.asterix.aql.expression.RunStatement;
-import org.apache.asterix.aql.expression.SetStatement;
-import org.apache.asterix.aql.expression.SubscribeFeedStatement;
-import org.apache.asterix.aql.expression.TypeDecl;
-import org.apache.asterix.aql.expression.TypeDropStatement;
-import org.apache.asterix.aql.expression.TypeExpression;
-import org.apache.asterix.aql.expression.WriteStatement;
-import org.apache.asterix.aql.util.FunctionUtils;
 import org.apache.asterix.common.config.AsterixCompilerProperties;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.config.DatasetConfig.ExternalDatasetTransactionState;
@@ -116,6 +76,45 @@
 import org.apache.asterix.file.FeedOperations;
 import org.apache.asterix.file.IndexOperations;
 import org.apache.asterix.formats.nontagged.AqlTypeTraitProvider;
+import org.apache.asterix.lang.aql.statement.SubscribeFeedStatement;
+import org.apache.asterix.lang.aql.util.FunctionUtils;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.expression.TypeExpression;
+import org.apache.asterix.lang.common.statement.CompactStatement;
+import org.apache.asterix.lang.common.statement.ConnectFeedStatement;
+import org.apache.asterix.lang.common.statement.CreateDataverseStatement;
+import org.apache.asterix.lang.common.statement.CreateFeedPolicyStatement;
+import org.apache.asterix.lang.common.statement.CreateFeedStatement;
+import org.apache.asterix.lang.common.statement.CreateFunctionStatement;
+import org.apache.asterix.lang.common.statement.CreateIndexStatement;
+import org.apache.asterix.lang.common.statement.CreatePrimaryFeedStatement;
+import org.apache.asterix.lang.common.statement.CreateSecondaryFeedStatement;
+import org.apache.asterix.lang.common.statement.DatasetDecl;
+import org.apache.asterix.lang.common.statement.DataverseDecl;
+import org.apache.asterix.lang.common.statement.DataverseDropStatement;
+import org.apache.asterix.lang.common.statement.DeleteStatement;
+import org.apache.asterix.lang.common.statement.DisconnectFeedStatement;
+import org.apache.asterix.lang.common.statement.DropStatement;
+import org.apache.asterix.lang.common.statement.ExternalDetailsDecl;
+import org.apache.asterix.lang.common.statement.FeedDropStatement;
+import org.apache.asterix.lang.common.statement.FeedPolicyDropStatement;
+import org.apache.asterix.lang.common.statement.FunctionDecl;
+import org.apache.asterix.lang.common.statement.FunctionDropStatement;
+import org.apache.asterix.lang.common.statement.IDatasetDetailsDecl;
+import org.apache.asterix.lang.common.statement.IndexDropStatement;
+import org.apache.asterix.lang.common.statement.InsertStatement;
+import org.apache.asterix.lang.common.statement.InternalDetailsDecl;
+import org.apache.asterix.lang.common.statement.LoadStatement;
+import org.apache.asterix.lang.common.statement.NodeGroupDropStatement;
+import org.apache.asterix.lang.common.statement.NodegroupDecl;
+import org.apache.asterix.lang.common.statement.Query;
+import org.apache.asterix.lang.common.statement.RefreshExternalDatasetStatement;
+import org.apache.asterix.lang.common.statement.RunStatement;
+import org.apache.asterix.lang.common.statement.SetStatement;
+import org.apache.asterix.lang.common.statement.TypeDecl;
+import org.apache.asterix.lang.common.statement.TypeDropStatement;
+import org.apache.asterix.lang.common.statement.WriteStatement;
+import org.apache.asterix.lang.common.struct.Identifier;
 import org.apache.asterix.metadata.IDatasetDetails;
 import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.metadata.MetadataManager;
diff --git a/asterix-app/src/main/java/org/apache/asterix/feeds/CentralFeedManager.java b/asterix-app/src/main/java/org/apache/asterix/feeds/CentralFeedManager.java
index 1945353..8183a06 100644
--- a/asterix-app/src/main/java/org/apache/asterix/feeds/CentralFeedManager.java
+++ b/asterix-app/src/main/java/org/apache/asterix/feeds/CentralFeedManager.java
@@ -25,13 +25,13 @@
 
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.parser.AQLParser;
 import org.apache.asterix.aql.translator.AqlTranslator;
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.common.feeds.api.ICentralFeedManager;
 import org.apache.asterix.common.feeds.api.IFeedLoadManager;
 import org.apache.asterix.common.feeds.api.IFeedTrackingManager;
+import org.apache.asterix.lang.aql.parser.AQLParser;
+import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.metadata.feeds.SocketMessageListener;
 import org.apache.asterix.om.util.AsterixAppContextInfo;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
@@ -97,7 +97,8 @@
             statements = parser.Statement();
             SessionConfig pc = new SessionConfig(out, OutputFormat.ADM);
             AqlTranslator translator = new AqlTranslator(statements, pc);
-            translator.compileAndExecute(AsterixAppContextInfo.getInstance().getHcc(), null, AqlTranslator.ResultDelivery.SYNC);
+            translator.compileAndExecute(AsterixAppContextInfo.getInstance().getHcc(), null,
+                    AqlTranslator.ResultDelivery.SYNC);
         }
     }
 
diff --git a/asterix-app/src/main/java/org/apache/asterix/feeds/FeedLifecycleListener.java b/asterix-app/src/main/java/org/apache/asterix/feeds/FeedLifecycleListener.java
index d7da85e..4ca9961 100644
--- a/asterix-app/src/main/java/org/apache/asterix/feeds/FeedLifecycleListener.java
+++ b/asterix-app/src/main/java/org/apache/asterix/feeds/FeedLifecycleListener.java
@@ -35,10 +35,6 @@
 
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.expression.DataverseDecl;
-import org.apache.asterix.aql.expression.DisconnectFeedStatement;
-import org.apache.asterix.aql.expression.Identifier;
 import org.apache.asterix.aql.translator.AqlTranslator;
 import org.apache.asterix.common.api.IClusterManagementWork;
 import org.apache.asterix.common.api.IClusterManagementWork.ClusterState;
@@ -56,6 +52,10 @@
 import org.apache.asterix.common.feeds.api.IFeedLifecycleListener;
 import org.apache.asterix.common.feeds.api.IIntakeProgressTracker;
 import org.apache.asterix.common.feeds.message.StorageReportFeedMessage;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.statement.DataverseDecl;
+import org.apache.asterix.lang.common.statement.DisconnectFeedStatement;
+import org.apache.asterix.lang.common.struct.Identifier;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.cluster.AddNodeWork;
diff --git a/asterix-app/src/main/java/org/apache/asterix/feeds/FeedsActivator.java b/asterix-app/src/main/java/org/apache/asterix/feeds/FeedsActivator.java
index ea40d9b..9e8864c 100644
--- a/asterix-app/src/main/java/org/apache/asterix/feeds/FeedsActivator.java
+++ b/asterix-app/src/main/java/org/apache/asterix/feeds/FeedsActivator.java
@@ -26,11 +26,11 @@
 
 import org.apache.asterix.api.common.SessionConfig;
 import org.apache.asterix.api.common.SessionConfig.OutputFormat;
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.expression.ConnectFeedStatement;
-import org.apache.asterix.aql.expression.DataverseDecl;
-import org.apache.asterix.aql.expression.Identifier;
 import org.apache.asterix.aql.translator.AqlTranslator;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.statement.ConnectFeedStatement;
+import org.apache.asterix.lang.common.statement.DataverseDecl;
+import org.apache.asterix.lang.common.struct.Identifier;
 import org.apache.asterix.om.util.AsterixAppContextInfo;
 import org.apache.hyracks.api.job.JobId;
 
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestCase.java b/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestCase.java
index fd56664..618faf6 100644
--- a/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestCase.java
+++ b/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestCase.java
@@ -27,18 +27,15 @@
 import java.io.Reader;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
-import java.util.List;
 
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-import org.apache.asterix.aql.base.Statement;
-import org.apache.asterix.aql.parser.AQLParser;
-import org.apache.asterix.aql.parser.ParseException;
 import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.aql.parser.AQLParser;
+import org.apache.asterix.lang.aql.parser.ParseException;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.junit.Test;
+
+import junit.framework.TestCase;
 
 public class AQLTestCase extends TestCase {
 
@@ -54,11 +51,10 @@
             AlgebricksException {
         Reader fis = new BufferedReader(new InputStreamReader(new FileInputStream(queryFile), "UTF-8"));
         AQLParser parser = new AQLParser(fis);
-        List<Statement> statements;
         GlobalConfig.ASTERIX_LOGGER.info(queryFile.toString());
         try {
-            statements = parser.parse();
-        } catch (ParseException e) {
+            parser.parse();
+        } catch (Exception e) {
             GlobalConfig.ASTERIX_LOGGER.warning("Failed while testing file " + fis);
             StringWriter sw = new StringWriter();
             PrintWriter writer = new PrintWriter(sw);
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestSuite.java b/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestSuite.java
index cef70f2..57a446a 100644
--- a/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestSuite.java
+++ b/asterix-app/src/test/java/org/apache/asterix/test/aql/AQLTestSuite.java
@@ -25,14 +25,13 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.asterix.lang.aql.parser.ParseException;
 import org.apache.commons.lang3.StringUtils;
 
-import org.apache.asterix.aql.parser.ParseException;
-
 public class AQLTestSuite extends TestSuite {
-    private static String AQLTS_PATH = StringUtils.join(new String[] { "src", "test", "resources", "AQLTS",
+    private static String AQLTS_PATH = StringUtils.join(new String[] { "src", "test", "resources", "parserts",
             "queries" + File.separator }, File.separator);
-    private static String AQLTS_SQL_LIKE_PATH = StringUtils.join(new String[] { "src", "test", "resources", "AQLTS",
+    private static String AQLTS_SQL_LIKE_PATH = StringUtils.join(new String[] { "src", "test", "resources", "parserts",
             "queries-sql-like" + File.separator }, File.separator);
 
     public static Test suite() throws ParseException, UnsupportedEncodingException, FileNotFoundException {
@@ -51,9 +50,7 @@
                 testSuite.addTest(new AQLTestCase(file));
             }
         }
-
         return testSuite;
-
     }
 
     public static void main(String args[]) throws Throwable {
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/dml/DmlTest.java b/asterix-app/src/test/java/org/apache/asterix/test/dml/DmlTest.java
index 63ac149..fdd4bc2 100644
--- a/asterix-app/src/test/java/org/apache/asterix/test/dml/DmlTest.java
+++ b/asterix-app/src/test/java/org/apache/asterix/test/dml/DmlTest.java
@@ -25,13 +25,12 @@
 import java.io.PrintWriter;
 import java.io.Reader;
 
-import org.junit.Test;
-
 import org.apache.asterix.api.common.AsterixHyracksIntegrationUtil;
 import org.apache.asterix.api.java.AsterixJavaClient;
 import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.test.aql.TestsUtils;
+import org.apache.asterix.test.aql.TestExecutor;
 import org.apache.asterix.test.base.AsterixTestHelper;
+import org.junit.Test;
 
 public class DmlTest {
 
@@ -40,12 +39,11 @@
     private static final String SEPARATOR = File.separator;
     private static final String PATH_BASE = "src" + SEPARATOR + "test" + SEPARATOR + "resources" + SEPARATOR + "dmlts"
             + SEPARATOR;
-    private static final String PATH_EXPECTED = PATH_BASE + "results" + SEPARATOR;
     private static final String PATH_SCRIPTS = PATH_BASE + "scripts" + SEPARATOR;
     private static final String LOAD_FOR_ENLIST_FILE = PATH_SCRIPTS + "load-cust.aql";
-    private static final String ENLIST_FILE = PATH_SCRIPTS + "enlist-scan-cust.aql";
 
     private static final PrintWriter ERR = new PrintWriter(System.err);
+    private final TestExecutor testExecutor = new TestExecutor();
 
     @Test
     public void enlistTest() throws Exception {
@@ -68,18 +66,10 @@
             loadReader.close();
         }
         asterixLoad.execute();
-        File enlistFile = new File(ENLIST_FILE);
-        int dot = enlistFile.getName().lastIndexOf('.');
-        String resultFileName = enlistFile.getName().substring(0, dot + 1) + ".adm";
-        File expectedFile = new File(PATH_EXPECTED + SEPARATOR + resultFileName);
-        File actualFile = new File(PATH_ACTUAL + SEPARATOR + resultFileName);
-        // Khurram
-        //TestsUtils.runScriptAndCompareWithResult(AsterixHyracksIntegrationUtil.getHyracksClientConnection(),
-                //enlistFile, ERR, expectedFile, actualFile);
 
         AsterixHyracksIntegrationUtil.deinit();
         for (String d : ASTERIX_DATA_DIRS) {
-            TestsUtils.deleteRec(new File(d));
+            testExecutor.deleteRec(new File(d));
         }
         outdir.delete();
     }
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataTest.java b/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataTest.java
index 29db874..3788606 100644
--- a/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataTest.java
+++ b/asterix-app/src/test/java/org/apache/asterix/test/metadata/MetadataTest.java
@@ -22,6 +22,12 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.asterix.api.common.AsterixHyracksIntegrationUtil;
+import org.apache.asterix.common.config.AsterixPropertiesAccessor;
+import org.apache.asterix.common.config.AsterixTransactionProperties;
+import org.apache.asterix.common.config.GlobalConfig;
+import org.apache.asterix.test.aql.TestExecutor;
+import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.AfterClass;
@@ -31,13 +37,6 @@
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import org.apache.asterix.api.common.AsterixHyracksIntegrationUtil;
-import org.apache.asterix.common.config.AsterixPropertiesAccessor;
-import org.apache.asterix.common.config.AsterixTransactionProperties;
-import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.test.aql.TestsUtils;
-import org.apache.asterix.testframework.context.TestCaseContext;
-
 /**
  * Executes the Metadata tests.
  */
@@ -47,11 +46,12 @@
     private TestCaseContext tcCtx;
 
     private static final String PATH_ACTUAL = "mdtest" + File.separator;
-    private static final String PATH_BASE = StringUtils.join(new String[] { "src", "test", "resources",
-            "metadata" + File.separator }, File.separator);
+    private static final String PATH_BASE = StringUtils
+            .join(new String[] { "src", "test", "resources", "metadata" + File.separator }, File.separator);
     private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
 
     private static AsterixTransactionProperties txnProperties;
+    private static final TestExecutor testExecutor = new TestExecutor();
 
     @BeforeClass
     public static void setUp() throws Exception {
@@ -78,7 +78,7 @@
 
         // clean up the files written by the ASTERIX storage manager
         for (String d : AsterixHyracksIntegrationUtil.getDataDirs()) {
-            TestsUtils.deleteRec(new File(d));
+            testExecutor.deleteRec(new File(d));
         }
     }
 
@@ -107,7 +107,7 @@
 
     @Test
     public void test() throws Exception {
-        TestsUtils.executeTest(PATH_ACTUAL, tcCtx, null, false);
+        testExecutor.executeTest(PATH_ACTUAL, tcCtx, null, false);
     }
 
 }
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/querygen/AQLToSQLPPConverter.java b/asterix-app/src/test/java/org/apache/asterix/test/querygen/AQLToSQLPPConverter.java
new file mode 100644
index 0000000..ede621b
--- /dev/null
+++ b/asterix-app/src/test/java/org/apache/asterix/test/querygen/AQLToSQLPPConverter.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.test.querygen;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.List;
+
+import org.apache.asterix.lang.aql.parser.AQLParser;
+import org.apache.asterix.lang.aql.util.AQLFormatPrintUtil;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.sqlpp.parser.SQLPPParser;
+import org.apache.commons.io.FileUtils;
+
+public class AQLToSQLPPConverter {
+
+    public static void convert(String dirName) throws Exception {
+        File dir = new File(dirName);
+        File target = new File(dirName + "_sqlpp");
+        FileUtils.deleteQuietly(target);
+        FileUtils.forceMkdir(target);
+        convert(dir, target);
+    }
+
+    private static void convert(File src, File dest) throws Exception {
+        if (src.isFile()) {
+            DataInputStream dis = new DataInputStream(new FileInputStream(src));
+            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(src)));
+            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dest)));
+            try {
+                String line = null;
+                while ((line = reader.readLine()) != null) {
+                    if (line.startsWith("/*") || line.startsWith(" *") || line.startsWith("*")) {
+                        writer.write(line + "\n");
+                    } else {
+                        break;
+                    }
+                }
+                writer.write("\n");
+                AQLParser parser = new AQLParser(dis);
+                List<Statement> statements = parser.parse();
+                dis.close();
+                String sqlString = AQLFormatPrintUtil.toSQLPPString(statements);
+                writer.write(sqlString);
+            } catch (Exception e) {
+                System.out.println("AQL parser fails at: " + src.getAbsolutePath());
+                //e.printStackTrace();
+            } finally {
+                dis.close();
+                reader.close();
+                writer.close();
+            }
+
+            BufferedReader sqlReader = new BufferedReader(new InputStreamReader(new FileInputStream(dest)));
+            try {
+                SQLPPParser sqlParser = new SQLPPParser(sqlReader);
+                sqlParser.parse();
+            } catch (Exception e) {
+                System.out.println("SQL++ parser cannot parse: ");
+                System.out.println(dest.getAbsolutePath());
+                e.printStackTrace();
+            } finally {
+                sqlReader.close();
+            }
+            return;
+        }
+        for (File child : src.listFiles()) {
+            String lastName = child.getName();
+            lastName = lastName.replaceAll("\\.aql", "\\.sqlpp");
+            File targetChild = new File(dest, lastName);
+            if (child.isDirectory()) {
+                FileUtils.forceMkdir(targetChild);
+            } else {
+                targetChild.createNewFile();
+            }
+            convert(child, targetChild);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        convert("src/test/resources/runtimets/queries");
+        convert("src/test/resources/optimizerts/queries");
+    }
+
+}
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java b/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
index 9524e0d..2cba6c8 100644
--- a/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
+++ b/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
@@ -31,6 +31,7 @@
 import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.external.dataset.adapter.FileSystemBasedAdapter;
 import org.apache.asterix.external.util.IdentitiyResolverFactory;
+import org.apache.asterix.test.aql.TestExecutor;
 import org.apache.asterix.test.aql.TestsUtils;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.asterix.testframework.xml.TestGroup;
@@ -53,12 +54,13 @@
     protected static final Logger LOGGER = Logger.getLogger(ExecutionTest.class.getName());
 
     protected static final String PATH_ACTUAL = "rttest" + File.separator;
-    protected static final String PATH_BASE = StringUtils.join(
-            new String[] { "src", "test", "resources", "runtimets" }, File.separator);
+    protected static final String PATH_BASE = StringUtils.join(new String[] { "src", "test", "resources", "runtimets" },
+            File.separator);
 
     protected static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
 
     protected static AsterixTransactionProperties txnProperties;
+    private final static TestExecutor testExecutor = new TestExecutor();
 
     protected static TestGroup FailedGroup;
 
@@ -88,7 +90,8 @@
 
         HDFSCluster.getInstance().setup();
 
-        // Set the node resolver to be the identity resolver that expects node names
+        // Set the node resolver to be the identity resolver that expects node
+        // names
         // to be node controller ids; a valid assumption in test environment.
         System.setProperty(FileSystemBasedAdapter.NODE_RESOLVER_FACTORY_PROPERTY,
                 IdentitiyResolverFactory.class.getName());
@@ -107,7 +110,7 @@
         }
         // clean up the files written by the ASTERIX storage manager
         for (String d : AsterixHyracksIntegrationUtil.getDataDirs()) {
-            TestsUtils.deleteRec(new File(d));
+            testExecutor.deleteRec(new File(d));
         }
         HDFSCluster.getInstance().cleanup();
 
@@ -123,10 +126,9 @@
             failedSuite.setQueryOffsetPath("queries");
             failedSuite.getTestGroup().add(FailedGroup);
             marshaller.marshal(failedSuite, temp);
-            System.err.println("The failed.xml is written to :" + temp.getAbsolutePath() +
-                    ". You can copy it to only.xml by the following cmd:" +
-                    "\rcp " + temp.getAbsolutePath() + " " +
-                    Paths.get("./src/test/resources/runtimets/only.xml").toAbsolutePath());
+            System.err.println("The failed.xml is written to :" + temp.getAbsolutePath()
+                    + ". You can copy it to only.xml by the following cmd:" + "\rcp " + temp.getAbsolutePath() + " "
+                    + Paths.get("./src/test/resources/runtimets/only.xml").toAbsolutePath());
         }
     }
 
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/runtime/RepeatedTest.java b/asterix-app/src/test/java/org/apache/asterix/test/runtime/RepeatedTest.java
index 370b8a1..edb05d4 100644
--- a/asterix-app/src/test/java/org/apache/asterix/test/runtime/RepeatedTest.java
+++ b/asterix-app/src/test/java/org/apache/asterix/test/runtime/RepeatedTest.java
@@ -32,13 +32,12 @@
 import org.junit.runners.model.FrameworkMethod;
 import org.junit.runners.model.Statement;
 
-import org.apache.asterix.test.aql.TestsUtils;
+import org.apache.asterix.test.aql.TestExecutor;
 import org.apache.asterix.test.runtime.RepeatRule.Repeat;
 import org.apache.asterix.testframework.context.TestCaseContext;
 
 /**
  * Runs runtime test cases that have been identified in the repeatedtestsuite.xml.
- * 
  * Each test is run 10000 times.
  */
 class RepeatRule implements MethodRule {
@@ -85,7 +84,8 @@
 public class RepeatedTest extends ExecutionTest {
 
     private int count;
-    
+    private final TestExecutor testExecutor = new TestExecutor();
+
     @Parameters
     public static Collection<Object[]> tests() throws Exception {
         Collection<Object[]> testArgs = buildTestsInXml(TestCaseContext.DEFAULT_REPEADED_TESTSUITE_XML_NAME);
@@ -104,6 +104,6 @@
     @Repeat(times = 10000)
     public void test() throws Exception {
         System.err.println("***** Test Count: " + (++count) + " ******");
-        TestsUtils.executeTest(PATH_ACTUAL, tcCtx, null, false);
+        testExecutor.executeTest(PATH_ACTUAL, tcCtx, null, false);
     }
 }
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java
new file mode 100644
index 0000000..61c6064
--- /dev/null
+++ b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.test.sqlpp;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.common.TestHelper;
+import org.junit.AfterClass;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.internal.AssumptionViolatedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class OptimizerParserTest {
+
+    private static final Logger LOGGER = Logger.getLogger(OptimizerParserTest.class.getName());
+
+    private static final String SEPARATOR = File.separator;
+    private static final String EXTENSION_QUERY = "sqlpp";
+    private static final String EXTENSION_RESULT = "ast";
+    private static final String FILENAME_IGNORE = "ignore.txt";
+    private static final String FILENAME_ONLY = "only.txt";
+    private static final String PATH_BASE = "src" + SEPARATOR + "test" + SEPARATOR + "resources" + SEPARATOR
+            + "optimizerts" + SEPARATOR;
+    private static final String PATH_QUERIES = PATH_BASE + "queries_sqlpp" + SEPARATOR;
+    private static final String PATH_EXPECTED = PATH_BASE + "results_parser_sqlpp" + SEPARATOR;
+    private static final String PATH_ACTUAL = "opt_parserts" + SEPARATOR;
+
+    private static final ArrayList<String> ignore = AsterixTestHelper.readFile(FILENAME_IGNORE, PATH_BASE);
+    private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE);
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        System.err.println("Starting SQL++ parser tests for runtime test queries");
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        File outdir = new File(PATH_ACTUAL);
+        File[] files = outdir.listFiles();
+        if (files == null || files.length == 0) {
+            outdir.delete();
+        }
+    }
+
+    private static void suiteBuild(File dir, Collection<Object[]> testArgs, String path) {
+        for (File file : dir.listFiles()) {
+            if (file.isDirectory() && !file.getName().startsWith(".")) {
+                suiteBuild(file, testArgs, path + file.getName() + SEPARATOR);
+            }
+            if (file.isFile() && file.getName().endsWith(EXTENSION_QUERY)) {
+                String resultFileName = AsterixTestHelper.extToResExt(file.getName(), EXTENSION_RESULT);
+                File expectedFile = new File(PATH_EXPECTED + path + resultFileName);
+                File actualFile = new File(PATH_ACTUAL + SEPARATOR + path.replace(SEPARATOR, "_") + resultFileName);
+                testArgs.add(new Object[] { file, expectedFile, actualFile });
+            }
+        }
+    }
+
+    @Parameters
+    public static Collection<Object[]> tests() {
+        Collection<Object[]> testArgs = new ArrayList<Object[]>();
+        suiteBuild(new File(PATH_QUERIES), testArgs, "");
+        return testArgs;
+    }
+
+    private File actualFile;
+    private File expectedFile;
+    private File queryFile;
+
+    private ParserTestExecutor parserTestExecutor = new ParserTestExecutor();
+
+    public OptimizerParserTest(File queryFile, File expectedFile, File actualFile) {
+        this.queryFile = queryFile;
+        this.expectedFile = expectedFile;
+        this.actualFile = actualFile;
+    }
+
+    @Test
+    public void test() throws Exception {
+        try {
+            String queryFileShort = queryFile.getPath().substring(PATH_QUERIES.length()).replace(SEPARATOR.charAt(0),
+                    '/');
+            if (!only.isEmpty()) {
+                boolean toRun = TestHelper.isInPrefixList(only, queryFileShort);
+                if (!toRun) {
+                    LOGGER.info("SKIP TEST: \"" + queryFile.getPath()
+                            + "\" \"only.txt\" not empty and not in \"only.txt\".");
+                }
+                Assume.assumeTrue(toRun);
+            }
+            boolean skipped = TestHelper.isInPrefixList(ignore, queryFileShort);
+            if (skipped) {
+                LOGGER.info("SKIP TEST: \"" + queryFile.getPath() + "\" in \"ignore.txt\".");
+            }
+            Assume.assumeTrue(!skipped);
+
+            LOGGER.info("RUN TEST: \"" + queryFile.getPath() + "\"");
+            parserTestExecutor.testSQLPPParser(queryFile, actualFile, expectedFile);
+        } catch (Exception e) {
+            if (!(e instanceof AssumptionViolatedException)) {
+                LOGGER.severe("Test \"" + queryFile.getPath() + "\" FAILED!");
+                throw new Exception("Test \"" + queryFile.getPath() + "\" FAILED!", e);
+            } else {
+                throw e;
+            }
+        }
+    }
+}
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
new file mode 100644
index 0000000..79ad9ed
--- /dev/null
+++ b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.test.sqlpp;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.asterix.common.config.GlobalConfig;
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.base.Statement.Kind;
+import org.apache.asterix.lang.common.statement.DataverseDecl;
+import org.apache.asterix.lang.common.statement.FunctionDecl;
+import org.apache.asterix.lang.common.statement.Query;
+import org.apache.asterix.lang.sqlpp.parser.SQLPPParser;
+import org.apache.asterix.lang.sqlpp.rewrites.SqlppRewriter;
+import org.apache.asterix.lang.sqlpp.util.FunctionUtils;
+import org.apache.asterix.lang.sqlpp.util.SqlppAstPrintUtil;
+import org.apache.asterix.metadata.declared.AqlMetadataProvider;
+import org.apache.asterix.test.aql.TestExecutor;
+import org.apache.asterix.testframework.context.TestCaseContext;
+import org.apache.asterix.testframework.context.TestFileContext;
+import org.apache.asterix.testframework.xml.TestCase.CompilationUnit;
+import org.apache.asterix.testframework.xml.TestGroup;
+
+import junit.extensions.PA;
+
+public class ParserTestExecutor extends TestExecutor {
+
+    @Override
+    public void executeTest(String actualPath, TestCaseContext testCaseCtx, ProcessBuilder pb,
+            boolean isDmlRecoveryTest, TestGroup failedGroup) throws Exception {
+        int queryCount = 0;
+        List<CompilationUnit> cUnits = testCaseCtx.getTestCase().getCompilationUnit();
+        for (CompilationUnit cUnit : cUnits) {
+            LOGGER.info(
+                    "Starting [TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName() + " ... ");
+            List<TestFileContext> testFileCtxs = testCaseCtx.getTestFiles(cUnit);
+            List<TestFileContext> expectedResultFileCtxs = testCaseCtx.getExpectedResultFiles(cUnit);
+            for (TestFileContext ctx : testFileCtxs) {
+                File testFile = ctx.getFile();
+                try {
+                    if (queryCount >= expectedResultFileCtxs.size()) {
+                        throw new IllegalStateException("no result file for " + testFile.toString() + "; queryCount: "
+                                + queryCount + ", filectxs.size: " + expectedResultFileCtxs.size());
+                    }
+
+                    // Runs the test query.
+                    File actualResultFile = testCaseCtx.getActualResultFile(cUnit, new File(actualPath));
+                    File expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
+                    testSQLPPParser(testFile, actualResultFile, expectedResultFile);
+
+                    LOGGER.info(
+                            "[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName() + " PASSED ");
+                    queryCount++;
+                } catch (Exception e) {
+                    System.err.println("testFile " + testFile.toString() + " raised an exception:");
+                    e.printStackTrace();
+                    if (cUnit.getExpectedError().isEmpty()) {
+                        System.err.println("...Unexpected!");
+                        if (failedGroup != null) {
+                            failedGroup.getTestCase().add(testCaseCtx.getTestCase());
+                        }
+                        throw new Exception("Test \"" + testFile + "\" FAILED!", e);
+                    } else {
+                        LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName()
+                                + " failed as expected: " + e.getMessage());
+                        System.err.println("...but that was expected.");
+                    }
+                }
+            }
+        }
+
+    }
+
+    // Tests the SQL++ parser.
+    public void testSQLPPParser(File queryFile, File actualResultFile, File expectedFile) throws Exception {
+        Reader reader = new BufferedReader(new InputStreamReader(new FileInputStream(queryFile), "UTF-8"));
+        actualResultFile.getParentFile().mkdirs();
+        PrintWriter writer = new PrintWriter(new FileOutputStream(actualResultFile));
+        SQLPPParser parser = new SQLPPParser(reader);
+        GlobalConfig.ASTERIX_LOGGER.info(queryFile.toString());
+        try {
+            List<Statement> statements = parser.parse();
+            List<FunctionDecl> functions = getDeclaredFunctions(statements);
+            String dvName = getDefaultDataverse(statements);
+            AqlMetadataProvider aqlMetadataProvider = mock(AqlMetadataProvider.class);
+
+            @SuppressWarnings("unchecked")
+            Map<String, String> config = mock(Map.class);
+            when(aqlMetadataProvider.getDefaultDataverseName()).thenReturn(dvName);
+            when(aqlMetadataProvider.getConfig()).thenReturn(config);
+            when(config.get(FunctionUtils.IMPORT_PRIVATE_FUNCTIONS)).thenReturn("true");
+
+            for (Statement st : statements) {
+                if (st.getKind() == Kind.QUERY) {
+                    Query query = (Query) st;
+                    SqlppRewriter rewriter = new SqlppRewriter(functions, query, aqlMetadataProvider);
+                    rewrite(rewriter);
+                }
+                SqlppAstPrintUtil.print(st, writer);
+            }
+            writer.close();
+            // Compares the actual result and the expected result.
+            runScriptAndCompareWithResult(queryFile, new PrintWriter(System.err), expectedFile, actualResultFile);
+        } catch (Exception e) {
+            GlobalConfig.ASTERIX_LOGGER.warning("Failed while testing file " + reader);
+            throw e;
+        } finally {
+            reader.close();
+            writer.close();
+        }
+    }
+
+    // Extracts declared functions.
+    private List<FunctionDecl> getDeclaredFunctions(List<Statement> statements) {
+        List<FunctionDecl> functionDecls = new ArrayList<FunctionDecl>();
+        for (Statement st : statements) {
+            if (st.getKind().equals(Statement.Kind.FUNCTION_DECL)) {
+                functionDecls.add((FunctionDecl) st);
+            }
+        }
+        return functionDecls;
+    }
+
+    // Gets the default dataverse for the input statements.
+    private String getDefaultDataverse(List<Statement> statements) {
+        for (Statement st : statements) {
+            if (st.getKind().equals(Statement.Kind.DATAVERSE_DECL)) {
+                DataverseDecl dv = (DataverseDecl) st;
+                return dv.getDataverseName().getValue();
+            }
+        }
+        return null;
+    }
+
+    // Rewrite queries.
+    // Note: we do not do inline function rewriting here because this needs real
+    // metadata access.
+    private void rewrite(SqlppRewriter rewriter) throws AsterixException {
+        PA.invokeMethod(rewriter, "inlineColumnAlias()");
+        PA.invokeMethod(rewriter, "variableCheckAndRewrite()");
+    }
+
+}
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/RuntimeParserTest.java b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/RuntimeParserTest.java
new file mode 100644
index 0000000..aca1e13
--- /dev/null
+++ b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/RuntimeParserTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.test.sqlpp;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import org.apache.asterix.test.aql.TestExecutor;
+import org.apache.asterix.testframework.context.TestCaseContext;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Runs the runtime test cases under
+ * 'asterix-app/src/test/resources/runtimets/queries_sqlpp'.
+ */
+@RunWith(Parameterized.class)
+public class RuntimeParserTest {
+
+    protected static final Logger LOGGER = Logger.getLogger(RuntimeParserTest.class.getName());
+
+    protected static final String PATH_ACTUAL = "runtime_parserts" + File.separator;
+    protected static final String PATH_BASE = StringUtils.join(new String[] { "src", "test", "resources", "runtimets" },
+            File.separator);
+
+    private final TestExecutor testExecutor = new ParserTestExecutor();
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        System.err.println("Starting SQL++ parser tests for runtime test queries");
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        File outdir = new File(PATH_ACTUAL);
+        File[] files = outdir.listFiles();
+        if (files == null || files.length == 0) {
+            outdir.delete();
+        }
+    }
+
+    @Parameters
+    public static Collection<Object[]> tests() throws Exception {
+        Collection<Object[]> testArgs = buildTestsInXml(TestCaseContext.ONLY_TESTSUITE_XML_NAME);
+        if (testArgs.size() == 0) {
+            testArgs = buildTestsInXml("testsuite_sqlpp_parser.xml");
+        }
+        return testArgs;
+    }
+
+    protected static Collection<Object[]> buildTestsInXml(String xmlfile) throws Exception {
+        Collection<Object[]> testArgs = new ArrayList<Object[]>();
+        TestCaseContext.Builder b = new TestCaseContext.Builder();
+        for (TestCaseContext ctx : b.build(new File(PATH_BASE), xmlfile)) {
+            testArgs.add(new Object[] { ctx });
+        }
+        return testArgs;
+    }
+
+    protected TestCaseContext tcCtx;
+
+    public RuntimeParserTest(TestCaseContext tcCtx) {
+        this.tcCtx = tcCtx;
+    }
+
+    @Test
+    public void test() throws Exception {
+        testExecutor.executeTest(PATH_ACTUAL, tcCtx, null, false);
+    }
+
+}
diff --git a/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java
new file mode 100644
index 0000000..a924d7c
--- /dev/null
+++ b/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.test.sqlpp;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.common.TestHelper;
+import org.junit.AfterClass;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.internal.AssumptionViolatedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class SmokeParserTest {
+
+    private static final Logger LOGGER = Logger.getLogger(SmokeParserTest.class.getName());
+
+    private static final String SEPARATOR = File.separator;
+    private static final String EXTENSION_QUERY = "sqlpp";
+    private static final String EXTENSION_RESULT = "ast";
+    private static final String FILENAME_IGNORE = "ignore.txt";
+    private static final String FILENAME_ONLY = "only.txt";
+    private static final String PATH_BASE = "src" + SEPARATOR + "test" + SEPARATOR + "resources" + SEPARATOR
+            + "parserts" + SEPARATOR;
+    private static final String PATH_QUERIES = PATH_BASE + "queries_sqlpp" + SEPARATOR;
+    private static final String PATH_EXPECTED = PATH_BASE + "results_parser_sqlpp" + SEPARATOR;
+    private static final String PATH_ACTUAL = "parserts" + SEPARATOR;
+
+    private static final ArrayList<String> ignore = AsterixTestHelper.readFile(FILENAME_IGNORE, PATH_BASE);
+    private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE);
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        System.err.println("Starting SQL++ parser smoke tests");
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        File outdir = new File(PATH_ACTUAL);
+        File[] files = outdir.listFiles();
+        if (files == null || files.length == 0) {
+            outdir.delete();
+        }
+    }
+
+    private static void suiteBuild(File dir, Collection<Object[]> testArgs, String path) {
+        for (File file : dir.listFiles()) {
+            if (file.isDirectory() && !file.getName().startsWith(".")) {
+                suiteBuild(file, testArgs, path + file.getName() + SEPARATOR);
+            }
+            if (file.isFile() && file.getName().endsWith(EXTENSION_QUERY)) {
+                String resultFileName = AsterixTestHelper.extToResExt(file.getName(), EXTENSION_RESULT);
+                File expectedFile = new File(PATH_EXPECTED + path + resultFileName);
+                File actualFile = new File(PATH_ACTUAL + SEPARATOR + path.replace(SEPARATOR, "_") + resultFileName);
+                testArgs.add(new Object[] { file, expectedFile, actualFile });
+            }
+        }
+    }
+
+    @Parameters
+    public static Collection<Object[]> tests() {
+        Collection<Object[]> testArgs = new ArrayList<Object[]>();
+        suiteBuild(new File(PATH_QUERIES), testArgs, "");
+        return testArgs;
+    }
+
+    private File actualFile;
+    private File expectedFile;
+    private File queryFile;
+
+    private ParserTestExecutor parserTestExecutor = new ParserTestExecutor();
+
+    public SmokeParserTest(File queryFile, File expectedFile, File actualFile) {
+        this.queryFile = queryFile;
+        this.expectedFile = expectedFile;
+        this.actualFile = actualFile;
+    }
+
+    @Test
+    public void test() throws Exception {
+        try {
+            String queryFileShort = queryFile.getPath().substring(PATH_QUERIES.length()).replace(SEPARATOR.charAt(0),
+                    '/');
+            if (!only.isEmpty()) {
+                boolean toRun = TestHelper.isInPrefixList(only, queryFileShort);
+                if (!toRun) {
+                    LOGGER.info("SKIP TEST: \"" + queryFile.getPath()
+                            + "\" \"only.txt\" not empty and not in \"only.txt\".");
+                }
+                Assume.assumeTrue(toRun);
+            }
+            boolean skipped = TestHelper.isInPrefixList(ignore, queryFileShort);
+            if (skipped) {
+                LOGGER.info("SKIP TEST: \"" + queryFile.getPath() + "\" in \"ignore.txt\".");
+            }
+            Assume.assumeTrue(!skipped);
+
+            LOGGER.info("RUN TEST: \"" + queryFile.getPath() + "\"");
+            parserTestExecutor.testSQLPPParser(queryFile, actualFile, expectedFile);
+        } catch (Exception e) {
+            if (!(e instanceof AssumptionViolatedException)) {
+                LOGGER.severe("Test \"" + queryFile.getPath() + "\" FAILED!");
+                throw new Exception("Test \"" + queryFile.getPath() + "\" FAILED!", e);
+            } else {
+                throw e;
+            }
+        }
+    }
+}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql
index f5f4dbf..0758ea0 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql
@@ -41,6 +41,6 @@
 write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm";
 
 for $o in dataset('DBLP')
-where /*+ skip-index */ contains($o.title, "Multimedia")
+where /*+ skip-index */ test.contains($o.title, "Multimedia")
 order by $o.id
 return $o
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.sqlpp
new file mode 100644
index 0000000..674e149
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.sqlpp
new file mode 100644
index 0000000..46be922
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_01.sqlpp
new file mode 100644
index 0000000..7852d42
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_01.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_02.sqlpp
new file mode 100644
index 0000000..004c2c8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_02.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_03.sqlpp
new file mode 100644
index 0000000..759c9e4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-join_03.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_01.sqlpp
new file mode 100644
index 0000000..b6cedb7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_01.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_02.sqlpp
new file mode 100644
index 0000000..467a6c0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_02.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_03.sqlpp
new file mode 100644
index 0000000..0c6f6d3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_03.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_04.sqlpp
new file mode 100644
index 0000000..0bfa882
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_04.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_04.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_05.sqlpp
new file mode 100644
index 0000000..389feb8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_05.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_05.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_06.sqlpp
new file mode 100644
index 0000000..f4e741b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-composite-key-prefix-join_06.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  fname : string,
+  lname : string
+}
+
+create  table Names(Name) primary key fname,lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_06.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..4c57e9e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-multipred.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ *                  We expect the additional predicates to be put into a select above the 
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Orders(OrderType) primary key oid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join-multipred.adm"
+select element {'customer':c,'order':o}
+from  Customers as c,
+      Orders as o
+where ((c.cid /*+ indexnl */  = o.cid) and (c.name < o.orderstatus) and (c.age < o.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-neg_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-neg_01.sqlpp
new file mode 100644
index 0000000..1806d5d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-neg_01.sqlpp
@@ -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  : This is a negative test, mis-spelt/incorrect HINT should result in
+ *                a plan not using an indexed-nested loops join strategy. We expect a hash join. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join-neg_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key1 = y.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-neg_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-neg_02.sqlpp
new file mode 100644
index 0000000..551bd8b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join-neg_02.sqlpp
@@ -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  : This is a negative test, mis-spelt/incorrect HINT should result in
+ *                a plan not using an indexed-nested loops join strategy. We expect a hash join. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join-neg_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key2 = y.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_01.sqlpp
new file mode 100644
index 0000000..4628891
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that hash-exchanges internal dataset DsTwo, then probes internal dataset DsOne’s primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key1 /*+ indexnl */  = y.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_02.sqlpp
new file mode 100644
index 0000000..4022363
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that hash-exchanges internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key2 /*+ indexnl */  = y.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_03.sqlpp
new file mode 100644
index 0000000..0ce834c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_03.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Orders(OrderType) primary key oid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_04.adm"
+select element {'customer':c,'order':o}
+from  Customers as c,
+      Orders as o
+where (c.cid /*+ indexnl */  = o.cid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_04.sqlpp
new file mode 100644
index 0000000..3e198aa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_04.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Orders(OrderType) primary key oid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_05.adm"
+select element {'customer':c,'order':o}
+from  Orders as o,
+      Customers as c
+where (o.cid /*+ indexnl */  = c.cid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_05.sqlpp
new file mode 100644
index 0000000..3dbb8e3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-equi-join_05.sqlpp
@@ -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    : Self-equi joins a dataset, Customers, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_06.adm"
+select element {'customer1':c1,'customer2':c2}
+from  Customers as c1,
+      Customers as c2
+where (c1.cid /*+ indexnl */  = c2.cid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-ge-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-ge-join_01.sqlpp
new file mode 100644
index 0000000..64f3c59
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-ge-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-ge-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key1 /*+ indexnl */  >= y.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-ge-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-ge-join_02.sqlpp
new file mode 100644
index 0000000..3c2e9f3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-ge-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-ge-join_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key2 /*+ indexnl */  <= y.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-gt-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-gt-join_01.sqlpp
new file mode 100644
index 0000000..e1e5ce2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-gt-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-gt-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key1 /*+ indexnl */  > y.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-gt-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-gt-join_02.sqlpp
new file mode 100644
index 0000000..49677d4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-gt-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-gt-join_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key2 /*+ indexnl */  < y.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-le-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-le-join_01.sqlpp
new file mode 100644
index 0000000..e22bed0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-le-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-le-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key1 /*+ indexnl */  <= y.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-le-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-le-join_02.sqlpp
new file mode 100644
index 0000000..8bcbcff
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-le-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-le-join_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key2 /*+ indexnl */  >= y.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-lt-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-lt-join_01.sqlpp
new file mode 100644
index 0000000..1e70a4d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-lt-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-lt-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key1 /*+ indexnl */  < y.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-lt-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-lt-join_02.sqlpp
new file mode 100644
index 0000000..0cd44d0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/primary-lt-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan. 
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne’s primary index. 
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestType as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create  table test1.DsOne(TestType) primary key key1;
+
+create  table test1.DsTwo(TestType) primary key key1;
+
+write output to nc1:"rttest/btree-index-join_primary-lt-join_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.key2 /*+ indexnl */  > y.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join-multiindex.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join-multiindex.sqlpp
new file mode 100644
index 0000000..c15319b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join-multiindex.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
+ *                  We first expect FacebookUsers' primary index to be used 
+ *                  to satisfy the range condition on it's primary key. 
+ *                  FacebookMessages has a secondary btree index on author-id-copy, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserType as
+ closed {
+  id : int32,
+  "id-copy" : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int32}},
+  employment : [EmploymentType]
+}
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int32,
+  "message-id-copy" : int32,
+  "author-id" : int32,
+  "author-id-copy" : int32,
+  "in-response-to" : int32?,
+  "sender-location" : point?,
+  message : string
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  index fbmIdxAutId  if not exists  on FacebookMessages ("author-id-copy") type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm"
+select element {'fbu-ID':user.id,'fbm-auth-ID':message."author-id",'uname':user.name,'message':message.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where ((user.id /*+ indexnl */  = message."author-id-copy") and (user.id >= 11000) and (user.id <= 12000))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..93cac14
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join-multipred.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the additional predicates to be put into a select above the 
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title) type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multipred.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.title /*+ indexnl */  = b.title) and (a.authors < b.authors) and (a.misc > b.misc))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_01.sqlpp
new file mode 100644
index 0000000..28d1996
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_01.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title) type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_02.sqlpp
new file mode 100644
index 0000000..368d5de
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_02.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  CSX has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on CSX (title) type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_03.sqlpp
new file mode 100644
index 0000000..817f1e5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index-join/secondary-equi-join_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Equi self-joins a dataset, DBLP, based on its title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index title_index  on DBLP (title) type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-01.sqlpp
new file mode 100644
index 0000000..390b32f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-01.sqlpp
@@ -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     : This test is intended to verify that the primary BTree index is used 
+ *                  : for an invocation of current-datetime()
+ *  Expected Result : Success
+ *  Date            : 27th Aug 2015
+ *	Author			: Steven Jacobs
+ */
+
+drop  database emergencyTest if exists;
+create  database emergencyTest;
+
+use emergencyTest;
+
+
+create type emergencyTest.CHPReport as
+{
+  id : int64,
+  timestamp : datetime,
+  title : string,
+  message : string
+}
+
+create  table CHPReports(CHPReport) primary key timestamp;
+
+select element emergency.message
+from  CHPReports as emergency
+where ((emergency.timestamp >= (emergencyTest."current-datetime"() - emergencyTest."day-time-duration"('PT10H'))) and (emergency.title = 'ghost'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-02.sqlpp
new file mode 100644
index 0000000..0f3577a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-02.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used 
+ *                  : for an invocation of current-datetime()
+ *  Expected Result : Success
+ *  Date            : 27th Aug 2015
+ *	Author			: Steven Jacobs
+ */
+
+drop  database emergencyTest if exists;
+create  database emergencyTest;
+
+use emergencyTest;
+
+
+create type emergencyTest.CHPReport as
+{
+  id : int64,
+  timestamp : datetime,
+  title : string,
+  message : string
+}
+
+create  table CHPReports(CHPReport) primary key timestamp;
+
+select element emergency
+from  CHPReports as emergency
+with  time as (emergencyTest."current-datetime"() - emergencyTest."day-time-duration"('PT10H'))
+where (emergency.timestamp >= time)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-03.sqlpp
new file mode 100644
index 0000000..ae94e7b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-03.sqlpp
@@ -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     : This test is intended to verify that the primary BTree index is used 
+ *                  : for an invocation of current-datetime()
+ *  Expected Result : Success
+ *  Date            : 27th Aug 2015
+ *	Author			: Steven Jacobs
+ */
+
+drop  database emergencyTest if exists;
+create  database emergencyTest;
+
+use emergencyTest;
+
+
+create type emergencyTest.CHPReport as
+{
+  id : int64,
+  timestamp : datetime,
+  title : string,
+  message : string
+}
+
+create  table CHPReports(CHPReport) primary key timestamp;
+
+select element emergency
+from  CHPReports as emergency
+where (emergency.timestamp >= emergencyTest."current-datetime"())
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-04.sqlpp
new file mode 100644
index 0000000..16b0fc6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-datetime-04.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test makes sure that the plan is still okay when not converted to index search
+ *  Expected Result : Success
+ *  Date            : 27th Aug 2015
+ *	Author			: Steven Jacobs
+ */
+
+drop  database emergencyTest if exists;
+create  database emergencyTest;
+
+use emergencyTest;
+
+
+create type emergencyTest.CHPReport as
+{
+  id : int64,
+  timestamp : datetime,
+  title : string,
+  message : string
+}
+
+create  table CHPReports(CHPReport) primary key id;
+
+select element emergency
+from  CHPReports as emergency
+where (emergency.timestamp >= emergencyTest."current-datetime"())
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-01.sqlpp
new file mode 100644
index 0000000..ac242c9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-01.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-01.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-02.sqlpp
new file mode 100644
index 0000000..078fbfc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-02.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-02.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Susan')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-03.sqlpp
new file mode 100644
index 0000000..70ebdf5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-03.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-03.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Isa')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-04.sqlpp
new file mode 100644
index 0000000..d0938fd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-04.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-04.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Vanpatten')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-05.sqlpp
new file mode 100644
index 0000000..5efab34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-05.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-05.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.fname != 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-06.sqlpp
new file mode 100644
index 0000000..47aae4e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-06.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-06.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.fname = 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-07.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-07.sqlpp
new file mode 100644
index 0000000..dcfdcc6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-07.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : in the optimized query plan. 
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-07.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where (emp.lname = 'Kim')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-08.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-08.sqlpp
new file mode 100644
index 0000000..c205a75
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-08.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used in the optimized query plan 
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-08.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Young Seok') and (emp.lname = 'Kim'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-09.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-09.sqlpp
new file mode 100644
index 0000000..2a1bbe2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-09.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-09.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') or (emp.lname = 'Malaika'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-10.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-10.sqlpp
new file mode 100644
index 0000000..7194424
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-10.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-10.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Alex') and (emp.lname < 'Zach'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-11.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-11.sqlpp
new file mode 100644
index 0000000..764a57e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-11.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan for predicates.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-11.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Allan') and (emp.lname < 'Zubi'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-12.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-12.sqlpp
new file mode 100644
index 0000000..0e000ca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-12.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-12.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Allan') and (emp.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-13.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-13.sqlpp
new file mode 100644
index 0000000..31002c8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-13.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-13.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') and (emp.lname < 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-14.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-14.sqlpp
new file mode 100644
index 0000000..d5c0fab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-14.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-14.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Michael') and (emp.lname <= 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-15.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-15.sqlpp
new file mode 100644
index 0000000..6fb032c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-15.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-15.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-16.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-16.sqlpp
new file mode 100644
index 0000000..f229494
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-16.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-16.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname >= 'Kevin') and (emp.fname <= 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-17.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-17.sqlpp
new file mode 100644
index 0000000..cea3c05
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-17.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-17.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname <= 'Craig') and (emp.lname > 'Kevin'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-18.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-18.sqlpp
new file mode 100644
index 0000000..9269f32
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-18.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : in the optimized query plan 
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-18.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname != 'Michael') and (emp.lname != 'Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-19.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-19.sqlpp
new file mode 100644
index 0000000..7a70c2a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-19.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-19.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname <= 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-20.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-20.sqlpp
new file mode 100644
index 0000000..23b158c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-20.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-20.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname >= 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-21.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-21.sqlpp
new file mode 100644
index 0000000..c9de7fb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-21.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-21.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-22.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-22.sqlpp
new file mode 100644
index 0000000..c290924
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-22.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-22.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Sofia')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-23.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-23.sqlpp
new file mode 100644
index 0000000..94366d8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-23.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-23.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Chen')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-24.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-24.sqlpp
new file mode 100644
index 0000000..7f68270
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-24.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-24.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-25.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-25.sqlpp
new file mode 100644
index 0000000..17bfe7b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-25.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-25.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Neil') and (emp.fname < 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-26.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-26.sqlpp
new file mode 100644
index 0000000..4414710
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-26.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-26.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Max') and (emp.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-27.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-27.sqlpp
new file mode 100644
index 0000000..1f5b044
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-27.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-27.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname <= 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-28.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-28.sqlpp
new file mode 100644
index 0000000..cfdd0f8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-28.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-28.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname < 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-29.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-29.sqlpp
new file mode 100644
index 0000000..1653fb8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-29.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-29.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname >= 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-30.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-30.sqlpp
new file mode 100644
index 0000000..ab70312
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-30.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-30.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname > 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-31.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-31.sqlpp
new file mode 100644
index 0000000..1f5341e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-31.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') and (emp.lname > 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-32.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-32.sqlpp
new file mode 100644
index 0000000..c579348
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-primary-32.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-32.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname < 'Julio') and (emp.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-33.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-33.sqlpp
new file mode 100644
index 0000000..1d588af
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-33.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-33.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-34.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-34.sqlpp
new file mode 100644
index 0000000..7db2833
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-34.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-34.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Susan')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-35.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-35.sqlpp
new file mode 100644
index 0000000..ae7992f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-35.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-35.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Isa')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-36.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-36.sqlpp
new file mode 100644
index 0000000..bdd6630
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-36.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-36.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Vanpatten')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-37.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-37.sqlpp
new file mode 100644
index 0000000..5dd5c02
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-37.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-37.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname != 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-38.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-38.sqlpp
new file mode 100644
index 0000000..20a4907
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-38.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-38.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname = 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-39.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-39.sqlpp
new file mode 100644
index 0000000..f6cea67
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-39.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-39.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.lname = 'Kim')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-40.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-40.sqlpp
new file mode 100644
index 0000000..a4ce4f9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-40.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan 
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-40.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Young Seok') and (emp.lname = 'Kim'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-41.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-41.sqlpp
new file mode 100644
index 0000000..26a412c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-41.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-41.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') or (emp.lname = 'Malaika'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-42.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-42.sqlpp
new file mode 100644
index 0000000..3242469
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-42.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-42.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Alex') and (emp.lname < 'Zach'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-43.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-43.sqlpp
new file mode 100644
index 0000000..88ca141
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-43.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-43.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Allan') and (emp.lname < 'Zubi'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-44.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-44.sqlpp
new file mode 100644
index 0000000..79a8c6b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-44.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-44.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Allan') and (emp.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-45.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-45.sqlpp
new file mode 100644
index 0000000..6b04a6c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-45.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-45.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') and (emp.lname < 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-46.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-46.sqlpp
new file mode 100644
index 0000000..17894da
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-46.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-46.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Michael') and (emp.lname <= 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-47.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-47.sqlpp
new file mode 100644
index 0000000..05f0eb0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-47.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-47.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-48.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-48.sqlpp
new file mode 100644
index 0000000..0d740e6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-48.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-48.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname >= 'Kevin') and (emp.fname <= 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-49.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-49.sqlpp
new file mode 100644
index 0000000..afd739f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-49.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname <= 'Craig') and (emp.lname > 'Kevin'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-50.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-50.sqlpp
new file mode 100644
index 0000000..a641886
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-50.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : in the optimized query plan 
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-50.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname != 'Michael') and (emp.lname != 'Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-51.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-51.sqlpp
new file mode 100644
index 0000000..48b4d8f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-51.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-51.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname <= 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-52.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-52.sqlpp
new file mode 100644
index 0000000..4b2f5df
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-52.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-52.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname >= 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-53.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-53.sqlpp
new file mode 100644
index 0000000..8d1ec8a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-53.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-53.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname <= 'Kevin') and (emp.fname <= 'Mary') and (emp.lname >= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-54.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-54.sqlpp
new file mode 100644
index 0000000..3f0ba33
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-54.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-54.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-55.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-55.sqlpp
new file mode 100644
index 0000000..fdf8e02
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-55.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-55.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Sofia')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-56.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-56.sqlpp
new file mode 100644
index 0000000..d7e6482
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-56.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-56.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Chen')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-57.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-57.sqlpp
new file mode 100644
index 0000000..e664250
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-57.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-58.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-58.sqlpp
new file mode 100644
index 0000000..cafa0c8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-58.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-58.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Neil') and (emp.fname < 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-59.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-59.sqlpp
new file mode 100644
index 0000000..9f316b3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-59.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-59.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Max') and (emp.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-60.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-60.sqlpp
new file mode 100644
index 0000000..2636b3c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-60.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-60.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.fname = 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-61.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-61.sqlpp
new file mode 100644
index 0000000..499b9ff
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-61.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-61.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname <= 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-62.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-62.sqlpp
new file mode 100644
index 0000000..45ef71b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-62.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-62.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') and (emp.lname > 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-63.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-63.sqlpp
new file mode 100644
index 0000000..b172a39
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/btree-index/btree-secondary-63.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-63.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname,lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname < 'Julio') and (emp.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/collocated.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/collocated.sqlpp
new file mode 100644
index 0000000..ee85e93
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/collocated.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 colocated if exists;
+create  database colocated;
+
+use colocated;
+
+
+create type colocated.UserType as
+{
+  uid : int32,
+  name : string,
+  lottery_numbers : {{int32}}
+}
+
+create type colocated.VisitorType as
+{
+  vid : int32,
+  name : string,
+  lottery_numbers : {{int32}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
+write output to nc1:"/tmp/fuzzy1.adm"
+select element {'user_name':user.name,'visitor_name':visitor.name}
+from  Users as user,
+      Visitors as visitor
+where (user.uid = visitor.vid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/consolidate-selects-complex.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/consolidate-selects-complex.sqlpp
new file mode 100644
index 0000000..2580817
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/consolidate-selects-complex.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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+write output to nc1:"rttest/consolidate-complex-selects.aql"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Transactions for Cooperative Environments'),
+      jacca as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.800000f),
+      jaccb as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.500000f),
+      jaccc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.300000f)
+where (jacca[0] and jaccb[0] and (paper.authors = 'testauth') and jaccc)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/consolidate-selects-simple.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/consolidate-selects-simple.sqlpp
new file mode 100644
index 0000000..e034b8c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/consolidate-selects-simple.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+write output to nc1:"rttest/consolidate-selects-simple.aql"
+select element c
+from  Customers as c
+where ((c.c_name = 'testname') and (c.c_address = 'testaddr') and (c.c_nationkey = 1) and (c.c_phone = '123456789'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/const-folding.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/const-folding.sqlpp
new file mode 100644
index 0000000..f742174
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/const-folding.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/divide.adm"
+{'a':(1 + 2),'b':['foo','bar'][0]}.b;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/count-tweets.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/count-tweets.sqlpp
new file mode 100644
index 0000000..04a3b15
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/count-tweets.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 twitter if exists;
+create  database twitter;
+
+use twitter;
+
+
+create type twitter.Tweet as
+{
+  id : int32,
+  tweetid : int64,
+  loc : point,
+  time : datetime,
+  text : string
+}
+
+create external  table TwitterData(Tweet) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/twitter/smalltweets.txt"),("format"="adm"));
+
+write output to nc1:"/tmp/count-tweets.adm"
+select element {'word':tok,'count':twitter.count(token)}
+from  TwitterData as t,
+      tokens as token
+with  tokens as twitter."word-tokens"(t.text)
+group by token as tok
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/cust_group_no_agg.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/cust_group_no_agg.sqlpp
new file mode 100644
index 0000000..bef6677
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/cust_group_no_agg.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 group_no_agg if exists;
+create  database group_no_agg;
+
+use group_no_agg;
+
+
+create type group_no_agg.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+write output to nc1:"/tmp/.adm"
+select element name
+from  Customers as c
+group by c.c_name as name
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/denorm-cust-order.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/denorm-cust-order.sqlpp
new file mode 100644
index 0000000..0bcdfaa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/denorm-cust-order.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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 custorder if exists;
+create  database custorder;
+
+use custorder;
+
+
+create type custorder.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type custorder.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type custorder.OrderType as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
+create  table Orders(OrderType) primary key oid on group1;
+
+write output to nc1:"/tmp/custorder.adm"
+select element {'cid':cid,'cust':cust,'cnt-orders':custorder.count(o),'orders':o}
+from  Customers as c,
+      Orders as o
+where (c.cid = o.cid)
+group by c.cid as cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-1.sqlpp
new file mode 100644
index 0000000..421975b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-1.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : string,
+  idx : string,
+  "no-idx" : string
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (idx) type btree;
+
+delete x from TestSet
+ where ((x.id = 'one') or (x.id = 'two'));
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-2.sqlpp
new file mode 100644
index 0000000..f6407be
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-2.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : string,
+  idx : string,
+  "no-idx" : string
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (idx) type btree;
+
+delete x from TestSet
+ where ((x.idx = 'one') or (x.idx = 'two'));
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-3.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-3.sqlpp
new file mode 100644
index 0000000..e7185e8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/disjunction-to-join-delete-3.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : string,
+  idx : string,
+  "no-idx" : string
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (idx) type btree;
+
+delete x from TestSet
+ where ((x."no-idx" = 'one') or (x."no-idx" = 'two'));
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/distinct_aggregate.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/distinct_aggregate.sqlpp
new file mode 100644
index 0000000..22df976
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/distinct_aggregate.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems_q1(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+write output to nc1:"rttest/tpch_q1_pricing_summary_report_nt.adm"
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'count_suppkey':tpch.count(g)}
+from  (
+    select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'l_suppkey':l_suppkey}
+    from  LineItems_q1 as l
+    where (l.l_shipdate <= '1998-09-02')
+    group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus,l.l_suppkey as l_suppkey
+) as g
+group by g.l_returnflag as l_returnflag,g.l_linestatus as l_linestatus
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/filter-nested.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/filter-nested.sqlpp
new file mode 100644
index 0000000..d9de921
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/filter-nested.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/filter-nested.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname with filter on nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.lname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-dblp-csx.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-dblp-csx.sqlpp
new file mode 100644
index 0000000..fc899bc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-dblp-csx.sqlpp
@@ -0,0 +1,85 @@
+/*
+ * 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 "fj-dblp-csx" if exists;
+create  database "fj-dblp-csx";
+
+use "fj-dblp-csx";
+
+
+create type "fj-dblp-csx".DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type "fj-dblp-csx".CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table CSX(CSXType) primary key id on group1;
+
+write output to nc1:"rttest/fj-dblp-csx.adm"
+select element {'idDBLP':idDBLP,'idCSX':idCSX}
+from  DBLP as paperDBLP,
+      tokensDBLP as prefixTokenDBLP,
+      CSX as paperCSX,
+      tokensCSX as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      unrankedTokensDBLP as "fj-dblp-csx"."counthashed-word-tokens"(paperDBLP.title),
+      tokensDBLP as (
+      select element i
+      from  unrankedTokensDBLP as token,
+            (
+          select element paper.title
+          from  DBLP as paper
+      ) as tokenRanked at i
+      where (token = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      unrankedTokensCSX as "fj-dblp-csx"."counthashed-word-tokens"(paperCSX.title),
+      tokensCSX as (
+      select element i
+      from  unrankedTokensCSX as token,
+            (
+          select element paper.title
+          from  DBLP as paper
+      ) as tokenRanked at i
+      where (token = tokenRanked)
+      order by i
+  )
+where (prefixTokenDBLP = prefixTokenCSX)
+group by idDBLP as idDBLP,idCSX as idCSX
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-phase1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-phase1.sqlpp
new file mode 100644
index 0000000..2b832ec
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-phase1.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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 rares03 if exists;
+create  database rares03;
+
+use rares03;
+
+
+create type rares03.UserType as
+{
+  uid : int32,
+  name : string,
+  lottery_numbers : {{int32}}
+}
+
+create type rares03.VisitorType as
+{
+  vid : int32,
+  name : string,
+  lottery_numbers : {{int32}}
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Users(UserType) primary key uid on group1;
+
+create  table Visitors(VisitorType) primary key vid on group1;
+
+write output to nc1:"/tmp/rares03.adm"
+select element {'uid':user.uid,'tokens':tokens}
+from  Users as user
+with  tokens as (
+      select element i
+      from  user.lottery_numbers as lottery_number,
+            (
+          select element item
+          from  Users as user,
+                user.lottery_numbers as lottery_number
+          group by lottery_number as item
+          with  count as rares03.count(user)
+          order by count desc
+      ) as token at i
+      where (lottery_number = token)
+      order by token
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-phase2-with-hints.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-phase2-with-hints.sqlpp
new file mode 100644
index 0000000..96abac0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/fj-phase2-with-hints.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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 fuzzyjoin_078 if exists;
+create  database fuzzyjoin_078;
+
+use fuzzyjoin_078;
+
+
+create type fuzzyjoin_078.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP_fuzzyjoin_078(DBLPType) primary key id on group1;
+
+write output to nc1:"rttest/fuzzyjoin_078.adm"
+select element {'id':paperDBLP.id,'tokens':tokensDBLP}
+from  DBLP_fuzzyjoin_078 as paperDBLP
+with  unrankedTokensDBLP as fuzzyjoin_078."counthashed-word-tokens"(paperDBLP.title),
+      tokensDBLP as (
+      select element i
+      from  unrankedTokensDBLP as token,
+            (
+          select element tokenGroupped
+          from  DBLP_fuzzyjoin_078 as paper,
+                fuzzyjoin_078."counthashed-word-tokens"(paper.title) as token
+          /* +hash */
+          group by token as tokenGroupped
+          order by fuzzyjoin_078.count(paper),tokenGroupped
+      ) as tokenRanked at i
+      where (token = tokenRanked)
+      order by i
+  )
+order by paperDBLP.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/hashjoin-with-unnest.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/hashjoin-with-unnest.sqlpp
new file mode 100644
index 0000000..b2b64fb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/hashjoin-with-unnest.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests that non-datascan unnests are pushed through join and 
+ *                : the query plan is rewritten as hybrid hash join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  name : string
+}
+
+create  table t1(TestType) primary key id;
+
+create  table t2(TestType) primary key id;
+
+write output to nc1:"rttest/hahsjoin-with-unnest.adm"
+select element {'t1':m,'t2':n}
+from  t1 as m,
+      t2 as n,
+      m.hobbies as a,
+      n.hobbies as b
+where (a = b)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inline-funs.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inline-funs.sqlpp
new file mode 100644
index 0000000..d815ea6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inline-funs.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"/tmp/inline_funs.adm"
+declare function f1() {
+(1 + test.f2())
+};
+declare function f2() {
+(2 + test.f3() + test.f3() + test.f3() + test.f4())
+};
+declare function f3() {
+(0 - 1)
+};
+declare function f4() {
+1001
+};
+select element test.f1();
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inlined_q18_large_volume_customer.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inlined_q18_large_volume_customer.sqlpp
new file mode 100644
index 0000000..a402585
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inlined_q18_large_volume_customer.sqlpp
@@ -0,0 +1,101 @@
+/*
+ * 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 inlined_q18_large_volume_customer if exists;
+create  database inlined_q18_large_volume_customer;
+
+use inlined_q18_large_volume_customer;
+
+
+create type inlined_q18_large_volume_customer.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type inlined_q18_large_volume_customer.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type inlined_q18_large_volume_customer.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+write output to nc1:"/tmp/inlined_q18_large_volume_customer.adm"
+select element {'c_name':c_name,'c_custkey':c_custkey,'o_orderkey':o_orderkey,'o_orderdate':o_orderdate,'o_totalprice':o_totalprice,'sum_quantity':inlined_q18_large_volume_customer.sum((
+        select element j.l_quantity
+        from  l as j
+    ))}
+from  Customers as c,
+      Orders as o,
+      (
+    select element {'l_orderkey':l_orderkey,'t_sum_quantity':inlined_q18_large_volume_customer.sum((
+            select element i.l_quantity
+            from  l as i
+        ))}
+    from  LineItems as l
+    group by l.l_orderkey as l_orderkey
+) as t,
+      LineItems as l
+where ((c.c_custkey = o.o_custkey) and ((o.o_orderkey = t.l_orderkey) and (t.t_sum_quantity > 300)) and (l.l_orderkey = o.o_orderkey))
+group by c.c_name as c_name,c.c_custkey as c_custkey,o.o_orderkey as o_orderkey,o.o_orderdate as o_orderdate,o.o_totalprice as o_totalprice
+order by o_totalprice desc,o_orderdate
+limit 100
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-dataset-with-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-dataset-with-index.sqlpp
new file mode 100644
index 0000000..f98e6b3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-dataset-with-index.sqlpp
@@ -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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset-with-index.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+create type test.Emp as
+ closed {
+  id : int32,
+  fname : string,
+  lname : string,
+  age : int32,
+  dept : string
+}
+
+create  table test.employee(Emp) primary key id;
+
+create  index idx_employee_first_name  on test.employee (fname) type btree;
+
+insert into test.employee
+select element {'id':(x.id + 10000),'fname':x.fname,'lname':x.lname,'age':x.age,'dept':x.dept}
+from  "test.employee" as x
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-dataset.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-dataset.sqlpp
new file mode 100644
index 0000000..c01c825
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-dataset.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset.aql
+ * Description     : This test is intended to test inserting into a dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.myDataType as
+{
+  id : int32
+}
+
+create  table myData(myDataType) primary key id;
+
+insert into myData
+select element {'id':(x.id + 1)}
+from  myData as x
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-joined-datasets.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-joined-datasets.sqlpp
new file mode 100644
index 0000000..b8f7f33
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/insert-and-scan-joined-datasets.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-joined-datasets.aql
+ * Description     : This test is intended to test inserting into a dataset where the incoming stream
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.myDataType as
+{
+  id : int32
+}
+
+create  table myData(myDataType) primary key id;
+
+create  table myData2(myDataType) primary key id;
+
+insert into myData
+select element {'id':(x.id + 1)}
+from  myData2 as x,
+      myData as y
+where (x.id = y.id)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/introhashpartitionmerge.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/introhashpartitionmerge.sqlpp
new file mode 100644
index 0000000..b3aa493
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/introhashpartitionmerge.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.TOKENSRANKEDADMType as
+ closed {
+  token : int32,
+  rank : int32
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table TOKENSRANKEDADM(TOKENSRANKEDADMType) primary key rank on group1;
+
+write output to nc1:"rttest/introhashpartitionmerge.adm"
+select element token2.rank
+from  TOKENSRANKEDADM as token1,
+      (
+    select element tokenRanked
+    from  TOKENSRANKEDADM as tokenRanked
+    order by tokenRanked.rank
+) as token2
+where (token1.token = token2.token)
+order by token2.rank
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-contains-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-contains-panic.sqlpp
new file mode 100644
index 0000000..6146565
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-contains-panic.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains-panic.adm"
+select element o
+from  DBLP as o
+where test.contains(o.title,'Mu')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-contains.sqlpp
new file mode 100644
index 0000000..ed755be
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-contains.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
new file mode 100644
index 0000000..be87443
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-check.sqlpp
new file mode 100644
index 0000000..3d39e56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-check.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm"
+select element o
+from  DBLP as o
+where test."edit-distance-check"(o.authors,'Amihay Motro',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-panic.sqlpp
new file mode 100644
index 0000000..6c4993a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance-panic.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-panic.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Amihay Motro') <= 5)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance.sqlpp
new file mode 100644
index 0000000..dfa9dc7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-edit-distance.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Amihay Motro') <= 1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..49564bc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-fuzzyeq-edit-distance.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query with ~= using edit-distance on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element o
+from  DBLP as o
+where (o.authors ~= 'Amihay Motro')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..0fa1bd5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query with ~= using Jaccard on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element o
+from  DBLP as o
+where (test."gram-tokens"(o.title,3,false) ~= test."gram-tokens"('Transactions for Cooperative Environments',3,false))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-jaccard-check.sqlpp
new file mode 100644
index 0000000..b39d0f7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-jaccard-check.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-jaccard.sqlpp
new file mode 100644
index 0000000..1c28b11
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ngram-jaccard.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false)) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-check-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-check-panic.sqlpp
new file mode 100644
index 0000000..859f585
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-check-panic.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-check-panic.adm"
+select element c
+from  Customers as c
+where test."edit-distance-check"(c.interests,['computers','wine','walking'],3)[0]
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-check.sqlpp
new file mode 100644
index 0000000..992933f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-check.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-check.adm"
+select element c
+from  Customers as c
+where test."edit-distance-check"(c.interests,['computers','wine','walking'],1)[0]
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-panic.sqlpp
new file mode 100644
index 0000000..3397de8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance-panic.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-panic.adm"
+select element c
+from  Customers as c
+where (test."edit-distance"(c.interests,['computers','wine','walking']) <= 3)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance.sqlpp
new file mode 100644
index 0000000..4f835d1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-edit-distance.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance.adm"
+select element c
+from  Customers as c
+where (test."edit-distance"(c.interests,['computers','wine','walking']) <= 1)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..af22885
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-fuzzyeq-edit-distance.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query with ~= using edit-distance on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element c
+from  Customers as c
+where (c.interests ~= ['computers','wine','walking'])
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..40df5f9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element c
+from  Customers as c
+where (c.interests ~= ['databases','computers','wine'])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-jaccard-check.sqlpp
new file mode 100644
index 0000000..b30a924
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-jaccard-check.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-jaccard-check.adm"
+select element c
+from  Customers as c
+where test."similarity-jaccard-check"(c.interests,['databases','computers','wine'],0.700000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-jaccard.sqlpp
new file mode 100644
index 0000000..635face
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/olist-jaccard.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-jaccard.adm"
+select element c
+from  Customers as c
+where (test."similarity-jaccard"(c.interests,['databases','computers','wine']) >= 0.700000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..f56d978
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element c
+from  Customers as c
+where (c.interests ~= {{'computers','wine','databases'}})
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-jaccard-check.sqlpp
new file mode 100644
index 0000000..266b18a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-jaccard-check.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm"
+select element c
+from  Customers as c
+where test."similarity-jaccard-check"(c.interests,{{'computers','wine','databases'}},0.700000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-jaccard.sqlpp
new file mode 100644
index 0000000..1e3c845
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/ulist-jaccard.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm"
+select element c
+from  Customers as c
+where (test."similarity-jaccard"(c.interests,{{'computers','databases','wine'}}) >= 0.700000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-contains.sqlpp
new file mode 100644
index 0000000..41f8234
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-contains.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..5ff613d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-fuzzyeq-jaccard.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.
+ */
+/*
+ * Description    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element o
+from  DBLP as o
+where (test."word-tokens"(o.title) ~= test."word-tokens"('Transactions for Cooperative Environments'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-jaccard-check.sqlpp
new file mode 100644
index 0000000..7317c59
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-jaccard-check.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-jaccard.sqlpp
new file mode 100644
index 0000000..faee18b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-basic/word-jaccard.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments')) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp
new file mode 100644
index 0000000..754e614
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using 
+ *                  two edit-distance-check function of which only the first can be optimized with an index. 
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  eda as test."edit-distance-check"(o.authors,'Amihay Motro',3),
+      edb as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where (eda[0] and edb[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp
new file mode 100644
index 0000000..dacf18b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using 
+ *                  two edit-distance-check function of which only the second can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  edb as test."edit-distance-check"(o.authors,'Amihay Motro',5),
+      eda as test."edit-distance-check"(o.authors,'Amihay Motro',3)
+where (edb[0] and eda[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
new file mode 100644
index 0000000..31b1e23
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
new file mode 100644
index 0000000..61925e7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
new file mode 100644
index 0000000..cddd14c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on the substring of the field.
+ *                  Tests that the optimizer rule correctly drills through the substring function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm"
+select element {'id':paper.id,'title':paper.title}
+from  DBLP as paper
+where test."edit-distance-check"(test.substring(paper.title,0,8),'datbase',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
new file mode 100644
index 0000000..72dbd3b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on individual word tokens.
+ *                  Tests that the optimizer rule correctly drills through the word-tokens function and existential query.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm"
+select element {'id':paper.id,'title':paper.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..32ebdc6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-jaccard-check-let.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..f5886b3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."gram-tokens"(paper.title,3,false),
+      query_tokens as test."gram-tokens"('Transactions for Cooperative Environments',3,false),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-edit-distance-check-let-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-edit-distance-check-let-panic.sqlpp
new file mode 100644
index 0000000..4be9f47
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-edit-distance-check-let-panic.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_olist-edit-distance-check-let-panic.adm"
+select element c
+from  Customers as c
+with  ed as test."edit-distance-check"(c.interests,['computers','wine','walking'],3)
+where ed[0]
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-edit-distance-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-edit-distance-check-let.sqlpp
new file mode 100644
index 0000000..f6c4ba1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-edit-distance-check-let.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_olist-edit-distance-check-let.adm"
+select element c
+from  Customers as c
+with  ed as test."edit-distance-check"(c.interests,['computers','wine','walking'],1)
+where ed[0]
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..5dbb332
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/olist-jaccard-check-let.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_olist-jaccard-check-let.adm"
+select element c
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.interests,['databases','computers','wine'],0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ulist-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ulist-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..05eaf9b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/ulist-jaccard-check-let.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_ulist-jaccard-check-let.adm"
+select element c
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.interests,['databases','computers','wine'],0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/word-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/word-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..9458c4c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/word-jaccard-check-let.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/word-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/word-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..a1e3a82
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-complex/word-jaccard-check-multi-let.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Transactions for Cooperative Environments'),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.800000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline.sqlpp
new file mode 100644
index 0000000..7f1951e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm"
+select element {'aauthors':a.authors,'bauthors':b.authors,'ed':ed}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance"(a.authors,b.authors)
+where ((ed < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance.sqlpp
new file mode 100644
index 0000000..82492f0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary. 
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance.adm"
+select element {'aauthors':a.authors,'bauthors':b.authors}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..e6d57c1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary. 
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'aauthors':a.authors,'bauthors':b.authors}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..6a4e7b4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'atitle':a.title,'btitle':b.title}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline.sqlpp
new file mode 100644
index 0000000..4bdcb05
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm"
+select element {'atitle':a.title,'btitle':b.title,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard.sqlpp
new file mode 100644
index 0000000..0981ab2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard.adm"
+select element {'atitle':a.title,'btitle':b.title}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline.sqlpp
new file mode 100644
index 0000000..456eba1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the edit-distance function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-edit-distance-inline.adm"
+select element {'ainterests':a.interests,'binterests':b.interests,'ed':ed}
+from  Customers as a,
+      Customers as b
+with  ed as test."edit-distance"(a.interests,b.interests)
+where ((ed <= 2) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance.sqlpp
new file mode 100644
index 0000000..89a9f07
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-edit-distance.adm"
+select element {'ainterests':a.interests,'binterests':b.interests}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.interests,b.interests) <= 2) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..16ddaf7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using edit distance of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'ainterests':a.interests,'binterests':b.interests}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..d5f9ad8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'ainterests':a.interests,'binterests':b.interests}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline.sqlpp
new file mode 100644
index 0000000..ba1f784
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-jaccard-inline.adm"
+select element {'ainterests':a.interests,'binterests':b.interests,'jacc':jacc}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard.sqlpp
new file mode 100644
index 0000000..c600a84
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-jaccard.adm"
+select element {'ainterests':a.interests,'binterests':b.interests}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..5039c74
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ulist-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'ainterests':a.interests,'binterests':b.interests}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline.sqlpp
new file mode 100644
index 0000000..5046dcf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ulist-jaccard-inline.adm"
+select element {'ainterests':a.interests,'binterests':b.interests,'jacc':jacc}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard.sqlpp
new file mode 100644
index 0000000..c8c310b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ulist-jaccard.adm"
+select element {'ainterests':a.interests,'binterests':b.interests}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..dc298c0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'atitle':a.title,'btitle':b.title}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline.sqlpp
new file mode 100644
index 0000000..318b202
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm"
+select element {'atitle':a.title,'btitle':b.title,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard.sqlpp
new file mode 100644
index 0000000..1f07f4a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-jaccard.adm"
+select element {'atitle':a.title,'btitle':b.title}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/issue741.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/issue741.sqlpp
new file mode 100644
index 0000000..f3ba2ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/issue741.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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  : Test that left-outer-join may use an available inverted index in index subtree.
+ * Issue        : 741              
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+{
+  screen_name : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  sender_location : point?,
+  send_time : datetime,
+  referred_topics : {{string}},
+  message_text : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index topicIIx  on TweetMessages (referred_topics) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_issue741.adm"
+select element {'tweet':t.tweetid,'similar-tweets':(
+        select element t2.tweetid
+        from  TweetMessages as t2
+        with  sim as test."similarity-jaccard-check"(t.referred_topics,t2.referred_topics,0.600000f)
+        where (sim[0] and (t2.tweetid != t.tweetid))
+    )}
+from  TweetMessages as t
+where ((t.send_time >= test.datetime('2011-06-18T14:10:17')) and (t.send_time < test.datetime('2011-06-18T15:10:17')))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
new file mode 100644
index 0000000..d29180d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
@@ -0,0 +1,79 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgKeywordIx  on TweetMessages ("message-text") type keyword;
+
+create  index msgNgramIx  on TweetMessages ("message-text") type ngram (3);
+
+create  index topicKeywordIx  on TweetMessages ("referred-topics") type keyword;
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm"
+select element {'tweet':{'id':t1.tweetid,'topics':t1."message-text"},'similar-tweets':(
+        select element {'id':t2.tweetid,'topics':t2."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1."message-text",t2."message-text",7)
+        where (sim[0] and (t2.tweetid != t1.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.sqlpp
new file mode 100644
index 0000000..5afe4b6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.sqlpp
@@ -0,0 +1,79 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgKeywordIx  on TweetMessages ("message-text") type keyword;
+
+create  index msgNgramIx  on TweetMessages ("message-text") type ngram (3);
+
+create  index topicKeywordIx  on TweetMessages ("referred-topics") type keyword;
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-jaccard-check_idx_01.adm"
+select element {'tweet':{'id':t1.tweetid,'topics':t1."referred-topics"},'similar-tweets':(
+        select element {'id':t2.tweetid,'topics':t2."referred-topics"}
+        from  TweetMessages as t2
+        with  sim as test."similarity-jaccard-check"(t1."referred-topics",t2."referred-topics",0.500000f)
+        where (sim[0] and (t2.tweetid != t1.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-contains.sqlpp
new file mode 100644
index 0000000..38dccaf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-contains.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      DBLP as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..89f490c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_02.sqlpp
new file mode 100644
index 0000000..4353249
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  CSX has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_03.sqlpp
new file mode 100644
index 0000000..91a2c8e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance-check function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_04.sqlpp
new file mode 100644
index 0000000..e32b243
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-check_04.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance-check function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_04.adm"
+select element {'arec':a,'brec':b,'ed':ed[1]}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance-check"(a.authors,b.authors,3)
+where (ed[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-contains.sqlpp
new file mode 100644
index 0000000..01fffe4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance-contains.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-contains function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-contains.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-contains"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_01.sqlpp
new file mode 100644
index 0000000..84842a0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_02.sqlpp
new file mode 100644
index 0000000..bfd9111
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  CSX has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_03.sqlpp
new file mode 100644
index 0000000..c27456f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_04.sqlpp
new file mode 100644
index 0000000..e302d06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-edit-distance_04.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index. 
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_03.adm"
+select element {'arec':a,'brec':b,'ed':ed}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance"(a.authors,b.authors)
+where ((ed < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
new file mode 100644
index 0000000..124f818
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp
new file mode 100644
index 0000000..8fc2a0c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  CSX has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_03.sqlpp
new file mode 100644
index 0000000..55880e4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_03.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on ~= using edit distance of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_03.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..a561118
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..a91dd7b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard their titles' 3-gram tokens.
+ *                  CSX has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_02.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..fdd7f86
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on ~= using Jaccard of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_03.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..9a3dd33
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_01.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..9c43865
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_02.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  CSX has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..3f3e334
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_03.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..90497fc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard-check_04.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc[1]}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)
+where (jacc[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_01.sqlpp
new file mode 100644
index 0000000..8a456c6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_01.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_02.sqlpp
new file mode 100644
index 0000000..b8bde23
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_02.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  CSX has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_03.sqlpp
new file mode 100644
index 0000000..63f919a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_03.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_04.sqlpp
new file mode 100644
index 0000000..a4ea206
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ngram-jaccard_04.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..ddabd13
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance-check function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (test."edit-distance-check"(a.interests,b.interests,3)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_02.sqlpp
new file mode 100644
index 0000000..1ac5ba3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance-check function of their interest lists.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance-check_02.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (test."edit-distance-check"(a.interests,b.interests,3)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_03.sqlpp
new file mode 100644
index 0000000..d3f3e68
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_03.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the edit-distance-check function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance-check_03.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where (test."edit-distance-check"(a.interests,b.interests,3)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_04.sqlpp
new file mode 100644
index 0000000..105b8df
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance-check_04.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the edit-distance-check function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance-check_04.adm"
+select element {'arec':a,'brec':b,'ed':ed[1]}
+from  Customers as a,
+      Customers as b
+with  ed as test."edit-distance-check"(a.interests,b.interests,3)
+where (ed[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_01.sqlpp
new file mode 100644
index 0000000..d5939e4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.interests,b.interests) <= 2) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_02.sqlpp
new file mode 100644
index 0000000..f96eb88
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance function of their interest lists.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance_02.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.interests,b.interests) <= 2) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_03.sqlpp
new file mode 100644
index 0000000..69fff61
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_03.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the edit-distance function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance_03.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where ((test."edit-distance"(a.interests,b.interests) <= 2) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_04.sqlpp
new file mode 100644
index 0000000..b0176eb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-edit-distance_04.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the edit-distance function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance_04.adm"
+select element {'arec':a,'brec':b,'ed':ed}
+from  Customers as a,
+      Customers as b
+with  ed as test."edit-distance"(a.interests,b.interests)
+where ((ed <= 2) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_01.sqlpp
new file mode 100644
index 0000000..05a758c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_01.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using edit distance of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_02.sqlpp
new file mode 100644
index 0000000..e3282e8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_02.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using edit distance of their interest lists.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_02.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_03.sqlpp
new file mode 100644
index 0000000..7d1fbf8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_03.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on ~= using edit distance of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_03.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where ((a.interests ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..56ec6d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..a9a066a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest lists.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_02.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..92608a3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_03.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on ~= using Jaccard of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_03.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..bbb9906
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard-check function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..e173199
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard-check function of their interest lists.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..0281d93
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_03.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard-check function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard-check_03.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..49801dd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard-check_04.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard-check function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard-check_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc[1]}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)
+where (jacc[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_01.sqlpp
new file mode 100644
index 0000000..b1e40f0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_02.sqlpp
new file mode 100644
index 0000000..1165362
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest lists.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_03.sqlpp
new file mode 100644
index 0000000..d30cfb0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_03.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard_03.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_04.sqlpp
new file mode 100644
index 0000000..ff40544
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/olist-jaccard_04.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..bb6c1bc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..863280d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest sets.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-fuzzyeq-jaccard_02.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..c333464
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_03.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on ~= using Jaccard of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-fuzzyeq-jaccard_03.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where ((a.interests /*+ indexnl */  ~= b.interests) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..6d91e5f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard-check function of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..e2e6953
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard-check function of their interest sets.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..4165db4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_03.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard-check function of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard-check_03.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..6e29270
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard-check_04.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard-check function of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard-check_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc[1]}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard-check"(a.interests,b.interests,0.700000f)
+where (jacc[0] and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_01.sqlpp
new file mode 100644
index 0000000..f468e97
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_02.sqlpp
new file mode 100644
index 0000000..57aa4c7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest sets.
+ *                  Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  index interests_index  on Customers2 (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_03.sqlpp
new file mode 100644
index 0000000..0a0e384
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_03.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard_03.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_04.sqlpp
new file mode 100644
index 0000000..60a47fe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/ulist-jaccard_04.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index interests_index  on Customers (interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.700000f) and (a.cid < b.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..07eafcc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..278e67b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  CSX has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on CSX (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_02.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..7059c4a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_03.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on ~= using Jaccard of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_03.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
new file mode 100644
index 0000000..a8af07c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy self joins a dataset, TweetMessages, based on the similarity-jaccard-check function of its text-messages' word tokens.
+ *                  TweetMessages has a keyword index on text-message and btree index on the primary key tweetid, and we expect the join to be 
+ *					transformed into btree and inverted indexed nested-loop joins. We test whether the join condition can be transformed into 
+ *					multiple indexed nested loop joins of various type of indexes.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm"
+select element {'t1':t1.tweetid,'t2':t2.tweetid,'sim':sim[1]}
+from  TweetMessages as t1,
+      TweetMessages as t2
+with  sim as test."similarity-jaccard-check"(test."word-tokens"(t1."message-text"),test."word-tokens"(t2."message-text"),0.600000f)
+where (sim[0] and (t1.tweetid < test.int64('20')) and (t2.tweetid != t1.tweetid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..d35694a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..963dee2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  CSX has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on CSX (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..9b7ffb2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..96fa6de
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard-check_04.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc[1]}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)
+where (jacc[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_01.sqlpp
new file mode 100644
index 0000000..8ba66ca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_02.sqlpp
new file mode 100644
index 0000000..e525469
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  CSX has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on CSX (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_03.sqlpp
new file mode 100644
index 0000000..e9d670d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_04.sqlpp
new file mode 100644
index 0000000..2782951
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/inverted-index-join/word-jaccard_04.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/join-super-key_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/join-super-key_01.sqlpp
new file mode 100644
index 0000000..0a4bd2b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/join-super-key_01.sqlpp
@@ -0,0 +1,100 @@
+/*
+ * 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 "join-super-key_1" if exists;
+create  database "join-super-key_1";
+
+use "join-super-key_1";
+
+
+create type "join-super-key_1".SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type "join-super-key_1".NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type "join-super-key_1".LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type "join-super-key_1".PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type "join-super-key_1".PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+write output to nc1:"/tmp/join-super-key_01.adm"
+create  table LineItems(LineItemType) primary key l_partkey,l_linenumber on group1;
+
+create  table PartSupp(PartSuppType) primary key ps_partkey,ps_suppkey on group1;
+
+select element {'l_partkey':li.l_partkey}
+from  LineItems as li,
+      PartSupp as ps
+where ((li.l_partkey = ps.ps_partkey) and (li.l_suppkey = ps.ps_suppkey) and (li.l_extendedprice = ps.ps_supplycost))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/join-super-key_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/join-super-key_02.sqlpp
new file mode 100644
index 0000000..7aab555
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/join-super-key_02.sqlpp
@@ -0,0 +1,100 @@
+/*
+ * 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 "join-super-key_01" if exists;
+create  database "join-super-key_01";
+
+use "join-super-key_01";
+
+
+create type "join-super-key_01".SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type "join-super-key_01".NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type "join-super-key_01".LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type "join-super-key_01".PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type "join-super-key_01".PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+write output to nc1:"/tmp/join-super-key_01.adm"
+create  table LineItems(LineItemType) primary key l_partkey,l_linenumber on group1;
+
+create  table PartSupp(PartSuppType) primary key ps_partkey,ps_suppkey on group1;
+
+select element {'l_partkey':li.l_partkey}
+from  PartSupp as ps,
+      LineItems as li
+where ((li.l_partkey = ps.ps_partkey) and (li.l_suppkey = ps.ps_suppkey) and (li.l_extendedprice = ps.ps_supplycost))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/limit-issue353.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/limit-issue353.sqlpp
new file mode 100644
index 0000000..e0b1b89
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/limit-issue353.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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  : This test case is to verify the fix for issue353
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+write output to nc1:"/tmp/push_limit.adm"
+select element {'l_returnflag':l.l_returnflag,'l_linestatus':l.l_linestatus,'l_shipmode':l.l_shipmode}
+from  LineItem as l
+limit 2
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/loj-super-key_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/loj-super-key_01.sqlpp
new file mode 100644
index 0000000..9215f6d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/loj-super-key_01.sqlpp
@@ -0,0 +1,103 @@
+/*
+ * 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 "loj-super-key_01" if exists;
+create  database "loj-super-key_01";
+
+use "loj-super-key_01";
+
+
+create type "loj-super-key_01".SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type "loj-super-key_01".NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type "loj-super-key_01".LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type "loj-super-key_01".PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type "loj-super-key_01".PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+write output to nc1:"/tmp/loj-super-key_01.adm"
+create  table LineItems(LineItemType) primary key l_partkey,l_linenumber on group1;
+
+create  table PartSupp(PartSuppType) primary key ps_partkey,ps_suppkey on group1;
+
+select element {'li':li,'partsupp':partsupp}
+from  LineItems as li
+with  partsupp as (
+      select element ps
+      from  PartSupp as ps
+      where ((li.l_partkey = ps.ps_partkey) and (li.l_suppkey = ps.ps_suppkey) and (li.l_extendedprice = ps.ps_supplycost))
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/loj-super-key_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/loj-super-key_02.sqlpp
new file mode 100644
index 0000000..a80fa61
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/loj-super-key_02.sqlpp
@@ -0,0 +1,103 @@
+/*
+ * 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 "loj-super-key_02" if exists;
+create  database "loj-super-key_02";
+
+use "loj-super-key_02";
+
+
+create type "loj-super-key_02".SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type "loj-super-key_02".NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type "loj-super-key_02".LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type "loj-super-key_02".PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type "loj-super-key_02".PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+write output to nc1:"/tmp/loj-super-key_01.adm"
+create  table LineItems(LineItemType) primary key l_partkey,l_linenumber on group1;
+
+create  table PartSupp(PartSuppType) primary key ps_partkey,ps_suppkey on group1;
+
+select element {'partsupp':ps,'li':items}
+from  PartSupp as ps
+with  items as (
+      select element li
+      from  LineItems as li
+      where ((li.l_partkey = ps.ps_partkey) and (li.l_suppkey = ps.ps_suppkey) and (li.l_extendedprice = ps.ps_supplycost))
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nest_aggregate.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nest_aggregate.sqlpp
new file mode 100644
index 0000000..2b67f09
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nest_aggregate.sqlpp
@@ -0,0 +1,137 @@
+/*
+ * 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  : This test case is to verify the fix for issue782
+ * https://code.google.com/p/asterixdb/issues/detail?id=782
+ * Expected Res : SUCCESS
+ * Date         : 2nd Jun 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
+select element {'nation_key':nation.n_nationkey,'name':nation.n_name,'aggregates':(
+        select element {'order_date':orderdate,'sum_price':sum}
+        from  Orders as orders,
+              Customer as customer
+        where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = nation.n_nationkey))
+        group by orders.o_orderdate as orderdate
+        with  sum as tpch.sum((
+              select element o.o_totalprice
+              from  orders as o
+          ))
+        order by sum
+        limit 3
+    )}
+from  Nation as nation,
+      SelectedNation as sn
+where (nation.n_nationkey = sn.n_nationkey)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/disjunction-to-join.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/disjunction-to-join.sqlpp
new file mode 100644
index 0000000..d5acf89
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/disjunction-to-join.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Disjunctive predicate should be transformed into collection scan.
+ *                  Secondary index should be used to probe the values retrieved from collection.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NestedTestType as
+{
+  idx : string
+}
+
+create type test.TestType as
+{
+  id : string,
+  "no-idx" : string,
+  nested : NestedTestType
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (nested.idx) type btree;
+
+select element x
+from  TestSet as x
+where ((x.nested.idx = 'one') or (x.nested.idx = 'two'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.sqlpp
new file mode 100644
index 0000000..36e4c79
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.sqlpp
new file mode 100644
index 0000000..bf0a60f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where ((t1.nested.countA /*+ indexnl */  = t2.nested.countB) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_01.sqlpp
new file mode 100644
index 0000000..b5db202
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_01.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  > emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  > emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_02.sqlpp
new file mode 100644
index 0000000..f6b191a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_02.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  < emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  < emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_03.sqlpp
new file mode 100644
index 0000000..141fd42
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-join_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  = emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  = emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_01.sqlpp
new file mode 100644
index 0000000..c8aee57
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_01.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  < emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  > emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_02.sqlpp
new file mode 100644
index 0000000..c38f606
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_02.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  > emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  < emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_03.sqlpp
new file mode 100644
index 0000000..05f5d9f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  > emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  = emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_04.sqlpp
new file mode 100644
index 0000000..cd462d3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_04.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_04.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  < emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  = emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_05.sqlpp
new file mode 100644
index 0000000..2ef6a91
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_05.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_05.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  = emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  > emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_06.sqlpp
new file mode 100644
index 0000000..d95fe11
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_06.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its primary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.Name as
+{
+  nested : Nametmp
+}
+
+create  table Names(Name) primary key nested.fname,nested.lname;
+
+write output to nc1:"rttest/btree-index-join_primary-composite-key-prefix-prefix-join_06.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  = emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  < emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..ded8580
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join-multipred.sqlpp
@@ -0,0 +1,83 @@
+/*
+ * 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    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ *                  We expect the additional predicates to be put into a select above the
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.OrderTypetmp as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create type test.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Orders(OrderType) primary key nested.oid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join-multipred.adm"
+select element {'customer':c.nested,'order':o.nested}
+from  Customers as c,
+      Orders as o
+where ((c.nested.cid /*+ indexnl */  = o.nested.cid) and (c.nested.name < o.nested.orderstatus) and (c.nested.age < o.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join-neg_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join-neg_01.sqlpp
new file mode 100644
index 0000000..fcb60c3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join-neg_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : This is a negative test, mis-spelt/incorrect HINT should result in
+ *                a plan not using an indexed-nested loops join strategy. We expect a hash join.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join-neg_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key1 = y.nested.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_01.sqlpp
new file mode 100644
index 0000000..2602ff3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that hash-exchanges internal dataset DsTwo, then probes internal dataset DsOne's primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key1 /*+ indexnl */  = y.nested.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_02.sqlpp
new file mode 100644
index 0000000..edac5f3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_02.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that hash-exchanges internal dataset DsTwo, then probes internal dataset DsOne's primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_02.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key2 /*+ indexnl */  = y.nested.key1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_03.sqlpp
new file mode 100644
index 0000000..75e669a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_03.sqlpp
@@ -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.
+ */
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.OrderTypetmp as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create type test.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Orders(OrderType) primary key nested.oid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_04.adm"
+select element {'customer':c.nested,'order':o.nested}
+from  Customers as c,
+      Orders as o
+where (c.nested.cid /*+ indexnl */  = o.nested.cid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_04.sqlpp
new file mode 100644
index 0000000..eb25a0c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_04.sqlpp
@@ -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.
+ */
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.OrderTypetmp as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create type test.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Orders(OrderType) primary key nested.oid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_05.adm"
+select element {'customer':c.nested,'order':o.nested}
+from  Orders as o,
+      Customers as c
+where (o.nested.cid /*+ indexnl */  = c.nested.cid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_05.sqlpp
new file mode 100644
index 0000000..98eee3e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-equi-join_05.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Self-equi joins a dataset, Customers, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+write output to nc1:"rttest/btree-index-join_primary-equi-join_06.adm"
+select element {'customer1':c1.nested,'customer2':c2.nested}
+from  Customers as c1,
+      Customers as c2
+where (c1.nested.cid /*+ indexnl */  = c2.nested.cid)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-ge-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-ge-join_01.sqlpp
new file mode 100644
index 0000000..a93546f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-ge-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOne's primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-ge-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key1 /*+ indexnl */  >= y.nested.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-gt-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-gt-join_01.sqlpp
new file mode 100644
index 0000000..e478f8f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-gt-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOnes primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-gt-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key1 /*+ indexnl */  > y.nested.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-le-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-le-join_01.sqlpp
new file mode 100644
index 0000000..ef88ee3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-le-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOnes primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-le-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key1 /*+ indexnl */  <= y.nested.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-lt-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-lt-join_01.sqlpp
new file mode 100644
index 0000000..e72eb83
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/primary-lt-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan.
+ *              : We expect a plan that broadcasts internal dataset DsTwo, then probes internal dataset DsOnes primary index.
+ * Expected Res : Success
+ * Date         : 29th November 2012
+ */
+
+drop  database test1 if exists;
+create  database test1;
+
+create type test1.TestTypetmp as
+{
+  key1 : int32,
+  key2 : int32,
+  fname : string,
+  lname : string
+}
+
+create type test1.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table test1.DsOne(TestType) primary key nested.key1;
+
+create  table test1.DsTwo(TestType) primary key nested.key1;
+
+write output to nc1:"rttest/btree-index-join_primary-lt-join_01.adm"
+select element x
+from  "test1.DsOne" as x,
+      "test1.DsTwo" as y
+where (x.nested.key1 /*+ indexnl */  < y.nested.key2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join-multiindex.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join-multiindex.sqlpp
new file mode 100644
index 0000000..ddfcffb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join-multiindex.sqlpp
@@ -0,0 +1,85 @@
+/*
+ * 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    : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
+ *                  We first expect FacebookUsers' primary index to be used
+ *                  to satisfy the range condition on it's primary key.
+ *                  FacebookMessages has a secondary btree index on author-id-copy, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserTypetmp as
+ closed {
+  id : int32,
+  "id-copy" : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int32}},
+  employment : [EmploymentType]
+}
+
+create type test.FacebookMessageTypetmp as
+ closed {
+  "message-id" : int32,
+  "message-id-copy" : int32,
+  "author-id" : int32,
+  "author-id-copy" : int32,
+  "in-response-to" : int32?,
+  "sender-location" : point?,
+  message : string
+}
+
+create type test.FacebookUserType as
+ closed {
+  nested : FacebookUserTypetmp
+}
+
+create type test.FacebookMessageType as
+ closed {
+  nested : FacebookMessageTypetmp
+}
+
+create  table FacebookUsers(FacebookUserType) primary key nested.id;
+
+create  table FacebookMessages(FacebookMessageType) primary key nested."message-id";
+
+create  index fbmIdxAutId  if not exists  on FacebookMessages (nested."author-id-copy") type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm"
+select element {'fbu-ID':user.nested.id,'fbm-auth-ID':message.nested."author-id",'uname':user.nested.name,'message':message.nested.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where ((user.nested.id /*+ indexnl */  = message.nested."author-id-copy") and (user.nested.id >= 11000) and (user.nested.id <= 12000))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..10adfc6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join-multipred.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the additional predicates to be put into a select above the
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index  on DBLP (nested.title) type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multipred.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.nested.title /*+ indexnl */  = b.nested.title) and (a.nested.authors < b.nested.authors) and (a.nested.misc > b.nested.misc))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join_01.sqlpp
new file mode 100644
index 0000000..41af3b9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index-join/secondary-equi-join_01.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index  on DBLP (nested.title) type btree;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.nested.title /*+ indexnl */  = b.nested.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-01.sqlpp
new file mode 100644
index 0000000..653591f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-01.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-01.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.fname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-02.sqlpp
new file mode 100644
index 0000000..2450dd8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-02.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-02.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.fname >= 'Susan')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-03.sqlpp
new file mode 100644
index 0000000..721e906
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-03.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.fname < 'Isa')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-04.sqlpp
new file mode 100644
index 0000000..b770353
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-04.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-04.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.fname <= 'Vanpatten')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-05.sqlpp
new file mode 100644
index 0000000..bea6079
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-05.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-05.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.fname != 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-06.sqlpp
new file mode 100644
index 0000000..5e9feea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-06.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-06.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.fname = 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-07.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-07.sqlpp
new file mode 100644
index 0000000..b05b895
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-07.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-07.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where (emp.nested.lname = 'Kim')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-08.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-08.sqlpp
new file mode 100644
index 0000000..9a9f663
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-08.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-08.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Young Seok') and (emp.nested.lname = 'Kim'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-09.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-09.sqlpp
new file mode 100644
index 0000000..eb5c695
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-09.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-09.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') or (emp.nested.lname = 'Malaika'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-10.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-10.sqlpp
new file mode 100644
index 0000000..46a5192
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-10.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-10.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Alex') and (emp.nested.lname < 'Zach'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-11.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-11.sqlpp
new file mode 100644
index 0000000..f5b32e7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-11.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan for predicates.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-11.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname > 'Allan') and (emp.nested.lname < 'Zubi'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-12.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-12.sqlpp
new file mode 100644
index 0000000..1a48bd8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-12.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-12.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname > 'Allan') and (emp.nested.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-13.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-13.sqlpp
new file mode 100644
index 0000000..f9a434f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-13.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-13.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') and (emp.nested.lname < 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-14.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-14.sqlpp
new file mode 100644
index 0000000..6ce745d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-14.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-14.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname >= 'Michael') and (emp.nested.lname <= 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-15.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-15.sqlpp
new file mode 100644
index 0000000..93f1835
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-15.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-15.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-16.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-16.sqlpp
new file mode 100644
index 0000000..aa403aa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-16.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-16.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-17.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-17.sqlpp
new file mode 100644
index 0000000..c85d28d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-17.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-17.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname <= 'Craig') and (emp.nested.lname > 'Kevin'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-18.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-18.sqlpp
new file mode 100644
index 0000000..228a3c3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-18.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is NOT used
+ *                  : in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-18.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp.nested
+from  testdst as emp
+where ((emp.nested.fname != 'Michael') and (emp.nested.lname != 'Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-19.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-19.sqlpp
new file mode 100644
index 0000000..1e8cbe3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-19.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-19.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-20.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-20.sqlpp
new file mode 100644
index 0000000..5eb4acd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-20.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-20.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-21.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-21.sqlpp
new file mode 100644
index 0000000..053f740
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-21.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-21.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname > 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-22.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-22.sqlpp
new file mode 100644
index 0000000..6fd56e4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-22.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-22.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname >= 'Sofia')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-23.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-23.sqlpp
new file mode 100644
index 0000000..870d33e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-23.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-23.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname < 'Chen')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-24.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-24.sqlpp
new file mode 100644
index 0000000..71fd2c7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-24.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-24.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname <= 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-25.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-25.sqlpp
new file mode 100644
index 0000000..a7bba9c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-25.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-25.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Neil') and (emp.nested.fname < 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-26.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-26.sqlpp
new file mode 100644
index 0000000..6f2e3d1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-26.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-26.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Max') and (emp.nested.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-27.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-27.sqlpp
new file mode 100644
index 0000000..1b8a684
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-27.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-27.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-28.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-28.sqlpp
new file mode 100644
index 0000000..4fec8ca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-28.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-28.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-29.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-29.sqlpp
new file mode 100644
index 0000000..cf82b34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-29.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-29.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-30.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-30.sqlpp
new file mode 100644
index 0000000..0984940
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-30.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 5th Feb 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-30.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-31.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-31.sqlpp
new file mode 100644
index 0000000..9980f11
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-31.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') and (emp.nested.lname > 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-32.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-32.sqlpp
new file mode 100644
index 0000000..3b5c1eb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-primary-32.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-32.adm"
+create type test.TestTypetmp as
+{
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.fname,nested.lname;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname < 'Julio') and (emp.nested.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-33.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-33.sqlpp
new file mode 100644
index 0000000..62577dd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-33.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-34.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-34.sqlpp
new file mode 100644
index 0000000..b946c58
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-34.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-32.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname >= 'Susan')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-35.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-35.sqlpp
new file mode 100644
index 0000000..a9cc94a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-35.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.
+ */
+/*
+ *  Description     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-33.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname < 'Isa')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-36.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-36.sqlpp
new file mode 100644
index 0000000..04fcab2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-36.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-34.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname <= 'Vanpatten')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-37.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-37.sqlpp
new file mode 100644
index 0000000..590a533
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-37.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-35.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname != 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-38.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-38.sqlpp
new file mode 100644
index 0000000..c0fe4fd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-38.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-36.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname = 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-39.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-39.sqlpp
new file mode 100644
index 0000000..1523dab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-39.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-37.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.lname = 'Kim')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-40.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-40.sqlpp
new file mode 100644
index 0000000..41f1ea1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-40.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-38.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Young Seok') and (emp.nested.lname = 'Kim'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-41.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-41.sqlpp
new file mode 100644
index 0000000..e327ebc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-41.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-39.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') or (emp.nested.lname = 'Malaika'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-42.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-42.sqlpp
new file mode 100644
index 0000000..7fdade6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-42.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-40.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Alex') and (emp.nested.lname < 'Zach'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-43.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-43.sqlpp
new file mode 100644
index 0000000..aa7d980
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-43.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-41.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Allan') and (emp.nested.lname < 'Zubi'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-44.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-44.sqlpp
new file mode 100644
index 0000000..69e07c3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-44.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-42.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Allan') and (emp.nested.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-45.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-45.sqlpp
new file mode 100644
index 0000000..6045cad
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-45.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-43.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') and (emp.nested.lname < 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-46.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-46.sqlpp
new file mode 100644
index 0000000..07f297e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-46.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-44.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Michael') and (emp.nested.lname <= 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-47.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-47.sqlpp
new file mode 100644
index 0000000..93e495b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-47.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-45.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-48.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-48.sqlpp
new file mode 100644
index 0000000..3471ac9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-48.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-46.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-49.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-49.sqlpp
new file mode 100644
index 0000000..3c14bc7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-49.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-47.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname <= 'Craig') and (emp.nested.lname > 'Kevin'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-50.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-50.sqlpp
new file mode 100644
index 0000000..f9d5030
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-50.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-48.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname != 'Michael') and (emp.nested.lname != 'Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-51.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-51.sqlpp
new file mode 100644
index 0000000..16a6018
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-51.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-52.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-52.sqlpp
new file mode 100644
index 0000000..b04d18f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-52.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-50.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-53.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-53.sqlpp
new file mode 100644
index 0000000..e2e860d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-53.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-51.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname <= 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname >= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-54.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-54.sqlpp
new file mode 100644
index 0000000..1cb7aea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-54.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-52.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname > 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-55.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-55.sqlpp
new file mode 100644
index 0000000..7a17c0f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-55.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-53.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname >= 'Sofia')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-56.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-56.sqlpp
new file mode 100644
index 0000000..d4324f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-56.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-54.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname < 'Chen')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-57.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-57.sqlpp
new file mode 100644
index 0000000..4fbc811
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-57.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-55.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname <= 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-58.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-58.sqlpp
new file mode 100644
index 0000000..3f312c7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-58.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-56.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Neil') and (emp.nested.fname < 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-59.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-59.sqlpp
new file mode 100644
index 0000000..d1ecbbf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-59.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Max') and (emp.nested.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-60.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-60.sqlpp
new file mode 100644
index 0000000..d32e6d1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-60.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.
+ */
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-58.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname) type btree;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname = 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-61.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-61.sqlpp
new file mode 100644
index 0000000..7767a27
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-61.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-61.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-62.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-62.sqlpp
new file mode 100644
index 0000000..386030e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-62.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-62.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') and (emp.nested.lname > 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-63.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-63.sqlpp
new file mode 100644
index 0000000..1bd6d66
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/btree-index/btree-secondary-63.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.
+ */
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-63.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname,nested.lname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname < 'Julio') and (emp.nested.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-contains-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-contains-panic.sqlpp
new file mode 100644
index 0000000..4a61bb6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-contains-panic.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains-panic.adm"
+select element o
+from  DBLP as o
+where test.contains(o.nested.title,'Mu')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-contains.sqlpp
new file mode 100644
index 0000000..5b0a0ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-contains.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
new file mode 100644
index 0000000..3b941cb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check.sqlpp
new file mode 100644
index 0000000..aa56210
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm"
+select element o
+from  DBLP as o
+where test."edit-distance-check"(o.nested.authors,'Amihay Motro',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-panic.sqlpp
new file mode 100644
index 0000000..aae398d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-panic.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-panic.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.nested.authors,'Amihay Motro') <= 5)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance.sqlpp
new file mode 100644
index 0000000..1d0cc53
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.nested.authors,'Amihay Motro') <= 1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..b247363
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query with ~= using edit-distance on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element o
+from  DBLP as o
+where (o.nested.authors ~= 'Amihay Motro')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..c387cb0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
@@ -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    : Tests whether an ngram_index is applied to optimize a selection query with ~= using Jaccard on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element o
+from  DBLP as o
+where (test."gram-tokens"(o.nested.title,3,false) ~= test."gram-tokens"('Transactions for Cooperative Environments',3,false))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-jaccard-check.sqlpp
new file mode 100644
index 0000000..8b97cb1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-jaccard-check.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-jaccard.sqlpp
new file mode 100644
index 0000000..1400a11
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ngram-jaccard.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false)) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check-panic.sqlpp
new file mode 100644
index 0000000..0ea3a7a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check-panic.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-check-panic.adm"
+select element c
+from  Customers as c
+where test."edit-distance-check"(c.nested.interests,['computers','wine','walking'],3)[0]
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check.sqlpp
new file mode 100644
index 0000000..044d99a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-check.adm"
+select element c
+from  Customers as c
+where test."edit-distance-check"(c.nested.interests,['computers','wine','walking'],1)[0]
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-panic.sqlpp
new file mode 100644
index 0000000..62dcac7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-panic.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-panic.adm"
+select element c
+from  Customers as c
+where (test."edit-distance"(c.nested.interests,['computers','wine','walking']) <= 3)
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance.sqlpp
new file mode 100644
index 0000000..1eefdde
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-edit-distance.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance.adm"
+select element c
+from  Customers as c
+where (test."edit-distance"(c.nested.interests,['computers','wine','walking']) <= 1)
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..4ab5a56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query with ~= using edit-distance on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element c
+from  Customers as c
+where (c.nested.interests ~= ['computers','wine','walking'])
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..7528155
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element c
+from  Customers as c
+where (c.nested.interests ~= ['databases','computers','wine'])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-jaccard-check.sqlpp
new file mode 100644
index 0000000..02a1918
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-jaccard-check.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-jaccard-check.adm"
+select element c
+from  Customers as c
+where test."similarity-jaccard-check"(c.nested.interests,['databases','computers','wine'],0.700000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-jaccard.sqlpp
new file mode 100644
index 0000000..1d12e90
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/olist-jaccard.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-jaccard.adm"
+select element c
+from  Customers as c
+where (test."similarity-jaccard"(c.nested.interests,['databases','computers','wine']) >= 0.700000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..eb29a16
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element c
+from  Customers as c
+where (c.nested.interests ~= {{'computers','wine','databases'}})
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-jaccard-check.sqlpp
new file mode 100644
index 0000000..22e4922
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-jaccard-check.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm"
+select element c
+from  Customers as c
+where test."similarity-jaccard-check"(c.nested.interests,{{'computers','wine','databases'}},0.700000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-jaccard.sqlpp
new file mode 100644
index 0000000..0fb7440
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/ulist-jaccard.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm"
+select element c
+from  Customers as c
+where (test."similarity-jaccard"(c.nested.interests,{{'computers','databases','wine'}}) >= 0.700000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-contains.sqlpp
new file mode 100644
index 0000000..b2d2ba3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-contains.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..54b0d56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.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.
+ */
+/*
+ * Description    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element o
+from  DBLP as o
+where (test."word-tokens"(o.nested.title) ~= test."word-tokens"('Transactions for Cooperative Environments'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-jaccard-check.sqlpp
new file mode 100644
index 0000000..519fbdd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-jaccard-check.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-jaccard.sqlpp
new file mode 100644
index 0000000..b4ac67e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-basic/word-jaccard.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments')) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp
new file mode 100644
index 0000000..8b31bb1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the first can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  eda as test."edit-distance-check"(o.nested.authors,'Amihay Motro',3),
+      edb as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where (eda[0] and edb[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp
new file mode 100644
index 0000000..b45f4d3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the second can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  edb as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5),
+      eda as test."edit-distance-check"(o.nested.authors,'Amihay Motro',3)
+where (edb[0] and eda[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
new file mode 100644
index 0000000..fdbd28a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
new file mode 100644
index 0000000..148f77b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
new file mode 100644
index 0000000..ba20bbe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on the substring of the field.
+ *                  Tests that the optimizer rule correctly drills through the substring function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm"
+select element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper
+where test."edit-distance-check"(test.substring(paper.nested.title,0,8),'datbase',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
new file mode 100644
index 0000000..95d27a8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on individual word tokens.
+ *                  Tests that the optimizer rule correctly drills through the word-tokens function and existential query.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm"
+select element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.nested.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..a3c19e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-let.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..3da4ee5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
@@ -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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."gram-tokens"(paper.nested.title,3,false),
+      query_tokens as test."gram-tokens"('Transactions for Cooperative Environments',3,false),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let-panic.sqlpp
new file mode 100644
index 0000000..8c75008
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let-panic.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_olist-edit-distance-check-let-panic.adm"
+select element c
+from  Customers as c
+with  ed as test."edit-distance-check"(c.nested.interests,['computers','wine','walking'],3)
+where ed[0]
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let.sqlpp
new file mode 100644
index 0000000..7c5ff03
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_olist-edit-distance-check-let.adm"
+select element c
+from  Customers as c
+with  ed as test."edit-distance-check"(c.nested.interests,['computers','wine','walking'],1)
+where ed[0]
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..fb9e5c2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/olist-jaccard-check-let.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_olist-jaccard-check-let.adm"
+select element c
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.nested.interests,['databases','computers','wine'],0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ulist-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ulist-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..0adc2ba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/ulist-jaccard-check-let.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_ulist-jaccard-check-let.adm"
+select element c
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.nested.interests,['databases','computers','wine'],0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..c2bc04a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-let.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..fff2dc6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-multi-let.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.nested.title),
+      query_tokens as test."word-tokens"('Transactions for Cooperative Environments'),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.800000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
new file mode 100644
index 0000000..f4fe12d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgNgramIx  on TweetMessages (nested."message-text") type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm"
+select element {'tweet':{'id':t1.nested.tweetid,'topics':t1.nested."message-text"},'similar-tweets':(
+        select element {'id':t2.nested.tweetid,'topics':t2.nested."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1.nested."message-text",t2.nested."message-text",7)
+        where (sim[0] and (t2.nested.tweetid != t1.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid > test.int64('240'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.sqlpp
new file mode 100644
index 0000000..a60538b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index topicKeywordIx  on TweetMessages (nested."referred-topics") type keyword;
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-jaccard-check_idx_01.adm"
+select element {'tweet':{'id':t1.nested.tweetid,'topics':t1.nested."referred-topics"},'similar-tweets':(
+        select element {'id':t2.nested.tweetid,'topics':t2.nested."referred-topics"}
+        from  TweetMessages as t2
+        with  sim as test."similarity-jaccard-check"(t1.nested."referred-topics",t2.nested."referred-topics",0.500000f)
+        where (sim[0] and (t2.nested.tweetid != t1.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid > test.int64('240'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..6308bb6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-check_01.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-contains.sqlpp
new file mode 100644
index 0000000..53b87e5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-contains.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-contains function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-contains.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-contains"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-inline.sqlpp
new file mode 100644
index 0000000..2dac7e2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-inline.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm"
+select element {'aauthors':a.nested.authors,'bauthors':b.nested.authors,'ed':ed}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance"(a.nested.authors,b.nested.authors)
+where ((ed < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance_01.sqlpp
new file mode 100644
index 0000000..1006106
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-edit-distance_01.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.nested.authors,b.nested.authors) < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
new file mode 100644
index 0000000..ac2c821
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.authors) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.nested.authors ~= b.nested.authors) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..23e6458
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,76 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.nested.title,3,false) ~= test."gram-tokens"(b.nested.title,3,false)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..acdc1e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard-check_01.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard-inline.sqlpp
new file mode 100644
index 0000000..c829209
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard-inline.sqlpp
@@ -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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm"
+select element {'atitle':a.nested.title,'btitle':b.nested.title,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard_01.sqlpp
new file mode 100644
index 0000000..94970e7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ngram-jaccard_01.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..013ee34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance-check_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance-check function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (test."edit-distance-check"(a.nested.interests,b.nested.interests,3)[0] and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance-inline.sqlpp
new file mode 100644
index 0000000..c218e34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance-inline.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the edit-distance function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-edit-distance-inline.adm"
+select element {'ainterests':a.nested.interests,'binterests':b.nested.interests,'ed':ed}
+from  Customers as a,
+      Customers as b
+with  ed as test."edit-distance"(a.nested.interests,b.nested.interests)
+where ((ed <= 2) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance_01.sqlpp
new file mode 100644
index 0000000..827c194
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-edit-distance_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.nested.interests,b.nested.interests) <= 2) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-edit-distance_01.sqlpp
new file mode 100644
index 0000000..20ac47d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-edit-distance_01.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using edit distance of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.nested.interests ~= b.nested.interests) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..b4cd886
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.nested.interests /*+ indexnl */  ~= b.nested.interests) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..40d94ea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard-check_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard-check function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.nested.interests,b.nested.interests,0.700000f)[0] and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard-inline.sqlpp
new file mode 100644
index 0000000..3890206
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard-inline.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_olist-jaccard-inline.adm"
+select element {'ainterests':a.nested.interests,'binterests':b.nested.interests,'jacc':jacc}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.nested.interests,b.nested.interests)
+where ((jacc >= 0.700000f) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard_01.sqlpp
new file mode 100644
index 0000000..8a9d98a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/olist-jaccard_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_olist-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.nested.interests,b.nested.interests) >= 0.700000f) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..b2007ad
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.7f";
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((a.nested.interests /*+ indexnl */  ~= b.nested.interests) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..4267ccd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard-check_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard-check function of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ( /*+ indexnl */ test."similarity-jaccard-check"(a.nested.interests,b.nested.interests,0.700000f)[0] and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard-inline.sqlpp
new file mode 100644
index 0000000..80ad630
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard-inline.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy self joins a dataset, Customers, based on the similarity-jaccard function of its interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ulist-jaccard-inline.adm"
+select element {'ainterests':a.nested.interests,'binterests':b.nested.interests,'jacc':jacc}
+from  Customers as a,
+      Customers as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.nested.interests,b.nested.interests)
+where ((jacc >= 0.700000f) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard_01.sqlpp
new file mode 100644
index 0000000..9252836
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/ulist-jaccard_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customer and Customer2, based on the similarity-jaccard function of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_ulist-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.nested.interests,b.nested.interests) >= 0.700000f) and (a.nested.cid < b.nested.cid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..f4630b4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.nested.title) ~= test."word-tokens"(b.nested.title)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
new file mode 100644
index 0000000..143f848
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
@@ -0,0 +1,76 @@
+/*
+ * 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    : Fuzzy self joins a dataset, TweetMessages, based on the similarity-jaccard-check function of its text-messages' word tokens.
+ *                  TweetMessages has a keyword index on text-message and btree index on the primary key tweetid, and we expect the join to be
+ *					transformed into btree and inverted indexed nested-loop joins. We test whether the join condition can be transformed into
+ *					multiple indexed nested loop joins of various type of indexes.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm"
+select element {'t1':t1.nested.tweetid,'t2':t2.nested.tweetid,'sim':sim[1]}
+from  TweetMessages as t1,
+      TweetMessages as t2
+with  sim as test."similarity-jaccard-check"(test."word-tokens"(t1.nested."message-text"),test."word-tokens"(t2.nested."message-text"),0.600000f)
+where (sim[0] and (t1.nested.tweetid < test.int64('20')) and (t2.nested.tweetid != t1.nested.tweetid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..e6180ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-check_01.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-inline.sqlpp
new file mode 100644
index 0000000..55a3381
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard-inline.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm"
+select element {'atitle':a.nested.title,'btitle':b.nested.title,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard_01.sqlpp
new file mode 100644
index 0000000..db05dd2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/inverted-index-join/word-jaccard_01.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
new file mode 100644
index 0000000..7cb8b59
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm"
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.nested."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
new file mode 100644
index 0000000..03e3a34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm"
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2.nested."sender-location",n) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_01.sqlpp
new file mode 100644
index 0000000..0458c9f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData1(MyRecordNested) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (nested.point) type rtree;
+
+write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_02.sqlpp
new file mode 100644
index 0000000..7893c9b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData2' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData1(MyRecordNested) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData2 (point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_03.sqlpp
new file mode 100644
index 0000000..35c6196
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_03.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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    : Self-joins a dataset on the intersection of its point attribute.
+ *                  The dataset has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData(MyRecordNested) primary key nested.id;
+
+create  index rtree_index  on MyData (nested.point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_03.adm"
+select element {'a':a,'b':b}
+from  MyData as a,
+      MyData as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/disjunction-to-join.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/disjunction-to-join.sqlpp
new file mode 100644
index 0000000..12514d2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/disjunction-to-join.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Disjunctive predicate should be transformed into collection scan.
+ *                  Secondary index should be used to probe the values retrieved from collection.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NestedTestType as
+{
+
+}
+
+create type test.TestType as
+{
+  id : string,
+  "no-idx" : string,
+  nested : NestedTestType
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (nested.idx:string) type btree enforced;
+
+select element x
+from  TestSet as x
+where ((x.nested.idx = 'one') or (x.nested.idx = 'two'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
new file mode 100644
index 0000000..66397ac6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
new file mode 100644
index 0000000..b704758
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgCountAIx  on TweetMessages (nested.countA:int32) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
new file mode 100644
index 0000000..32fb70c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where ((t1.nested.countA /*+ indexnl */  = t2.nested.countB) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
new file mode 100644
index 0000000..53bcc3b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgCountAIx  on TweetMessages (nested.countA:int32) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where ((t1.nested.countA /*+ indexnl */  = t2.nested.countB) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_01.sqlpp
new file mode 100644
index 0000000..d006faf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  > emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  > emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_02.sqlpp
new file mode 100644
index 0000000..aa673af
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_02.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  < emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  < emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_03.sqlpp
new file mode 100644
index 0000000..ac00e9c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_03.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  = emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  = emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
new file mode 100644
index 0000000..41e6642
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  < emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  > emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
new file mode 100644
index 0000000..9dd20ba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  > emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  < emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
new file mode 100644
index 0000000..8d384b4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  > emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  = emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
new file mode 100644
index 0000000..68e4f37
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_04.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  < emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  = emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
new file mode 100644
index 0000000..f551416
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_05.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  = emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  > emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
new file mode 100644
index 0000000..03fc651
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Nametmp as
+{
+  id : int32
+}
+
+create type test.NameType as
+{
+  nested : Nametmp
+}
+
+create  table Names(NameType) primary key nested.id;
+
+create  index Name_idx  on Names (nested.fname:string,lnested.name:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_06.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.nested.fname /*+ indexnl */  = emp2.nested.fname) and (emp1.nested.lname /*+ indexnl */  < emp2.nested.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multiindex.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multiindex.sqlpp
new file mode 100644
index 0000000..4a2f0b5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multiindex.sqlpp
@@ -0,0 +1,84 @@
+/*
+ * 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    : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
+ *                  We first expect FacebookUsers' primary index to be used
+ *                  to satisfy the range condition on it's primary key.
+ *                  FacebookMessages has a secondary btree index on author-id-copy, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserTypetmp as
+ closed {
+  id : int32,
+  "id-copy" : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int32}},
+  employment : [EmploymentType]
+}
+
+create type test.FacebookMessageTypetmp as
+{
+  "message-id" : int32,
+  "message-id-copy" : int32,
+  "author-id" : int32,
+  "in-response-to" : int32?,
+  "sender-location" : point?,
+  message : string
+}
+
+create type test.FacebookUserType as
+ closed {
+  nested : FacebookUserTypetmp
+}
+
+create type test.FacebookMessageType as
+ closed {
+  nested : FacebookMessageTypetmp
+}
+
+create  table FacebookUsers(FacebookUserType) primary key nested.id;
+
+create  table FacebookMessages(FacebookMessageType) primary key nested."message-id";
+
+create  index fbmIdxAutId  if not exists  on FacebookMessages (nested."author-id-copy":int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm"
+select element {'fbu-ID':user.nested.id,'fbm-auth-ID':message.nested."author-id",'uname':user.nested.name,'message':message.nested.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where ((user.nested.id /*+ indexnl */  = message.nested."author-id-copy") and (user.nested.id >= 11000) and (user.nested.id <= 12000))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..b2f3fa3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multipred.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the additional predicates to be put into a select above the
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index  on DBLP (nested.title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multipred.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.nested.title /*+ indexnl */  = b.nested.title) and (a.nested.authors < b.nested.authors) and (a.nested.misc > b.nested.misc))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_01.sqlpp
new file mode 100644
index 0000000..5ca59ca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_01.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index  on DBLP (nested.title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.nested.title /*+ indexnl */  = b.nested.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_02.sqlpp
new file mode 100644
index 0000000..e6b59f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_02.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Equi joins two datasets, closed DBLP and open CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index  on CSX (nested.title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.nested.title /*+ indexnl */  = b.nested.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_03.sqlpp
new file mode 100644
index 0000000..4ebdfc7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_03.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Equi joins two open datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index_DBLP  on DBLP (nested.title:string) type btree enforced;
+
+create  index title_index_CSX  on CSX (nested.title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.nested.title /*+ indexnl */  = b.nested.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_04.sqlpp
new file mode 100644
index 0000000..6877a7f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_04.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Self-joins dataset DBLP, based on it's title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+{
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index title_index  on DBLP (nested.title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_04.adm"
+select element {'arec':a,'arec2':a2}
+from  DBLP as a,
+      DBLP as a2
+where (a.nested.title /*+ indexnl */  = a2.nested.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_05.sqlpp
new file mode 100644
index 0000000..1dc52af
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_05.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Equi joins two open datasets, open DBLP and closed CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index title_index  on DBLP (nested.title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_05.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.nested.title /*+ indexnl */  = b.nested.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-33.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-33.sqlpp
new file mode 100644
index 0000000..66a680f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-33.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-39.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-34.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-34.sqlpp
new file mode 100644
index 0000000..2e8b979
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-34.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-32.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname >= 'Susan')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-35.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-35.sqlpp
new file mode 100644
index 0000000..6a637cf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-35.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-33.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname < 'Isa')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-36.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-36.sqlpp
new file mode 100644
index 0000000..6843fc8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-36.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-34.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname <= 'Vanpatten')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-37.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-37.sqlpp
new file mode 100644
index 0000000..2ca1b99
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-37.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-35.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname != 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-38.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-38.sqlpp
new file mode 100644
index 0000000..8e131b3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-38.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-36.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname = 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-39.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-39.sqlpp
new file mode 100644
index 0000000..64cf6ed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-39.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-37.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.lname = 'Kim')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-40.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-40.sqlpp
new file mode 100644
index 0000000..a6866bd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-40.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-38.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Young Seok') and (emp.nested.lname = 'Kim'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-41.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-41.sqlpp
new file mode 100644
index 0000000..4111bdb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-41.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-39.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') or (emp.nested.lname = 'Malaika'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-42.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-42.sqlpp
new file mode 100644
index 0000000..ced0a75
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-42.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-40.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Alex') and (emp.nested.lname < 'Zach'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-43.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-43.sqlpp
new file mode 100644
index 0000000..99ab006
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-43.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-41.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Allan') and (emp.nested.lname < 'Zubi'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-44.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-44.sqlpp
new file mode 100644
index 0000000..409c15e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-44.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-42.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Allan') and (emp.nested.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-45.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-45.sqlpp
new file mode 100644
index 0000000..7be8ee7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-45.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-43.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') and (emp.nested.lname < 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-46.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-46.sqlpp
new file mode 100644
index 0000000..2a439de
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-46.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-44.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Michael') and (emp.nested.lname <= 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-47.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-47.sqlpp
new file mode 100644
index 0000000..4555731
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-47.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-45.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-48.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-48.sqlpp
new file mode 100644
index 0000000..9488631
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-48.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-46.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-49.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-49.sqlpp
new file mode 100644
index 0000000..c638c3e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-49.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-47.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname <= 'Craig') and (emp.nested.lname > 'Kevin'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-50.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-50.sqlpp
new file mode 100644
index 0000000..86a4e80
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-50.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-48.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname != 'Michael') and (emp.nested.lname != 'Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-51.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-51.sqlpp
new file mode 100644
index 0000000..d8ab1cc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-51.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-52.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-52.sqlpp
new file mode 100644
index 0000000..ab1a592
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-52.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-50.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname >= 'Kevin') and (emp.nested.fname < 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-53.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-53.sqlpp
new file mode 100644
index 0000000..be5fa7e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-53.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-51.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Craig') and (emp.nested.lname <= 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname >= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-54.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-54.sqlpp
new file mode 100644
index 0000000..72cdf55
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-54.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-52.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname > 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-55.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-55.sqlpp
new file mode 100644
index 0000000..847f47d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-55.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-53.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname >= 'Sofia')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-56.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-56.sqlpp
new file mode 100644
index 0000000..98aeb72
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-56.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-54.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname < 'Chen')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-57.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-57.sqlpp
new file mode 100644
index 0000000..0448bbb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-57.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-55.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname <= 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-58.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-58.sqlpp
new file mode 100644
index 0000000..0b1760c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-58.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-56.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Neil') and (emp.nested.fname < 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-59.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-59.sqlpp
new file mode 100644
index 0000000..25d2a86
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-59.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname >= 'Max') and (emp.nested.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-60.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-60.sqlpp
new file mode 100644
index 0000000..6cb8dd2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-60.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-58.adm"
+create type test.TestTypetmp as
+{
+  id : int32,
+  lname : string
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.nested.fname = 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-61.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-61.sqlpp
new file mode 100644
index 0000000..33511e5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-61.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-59.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname > 'Craig') and (emp.nested.lname > 'Kevin') and (emp.nested.fname <= 'Mary') and (emp.nested.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-62.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-62.sqlpp
new file mode 100644
index 0000000..d21967a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-62.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-62.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname = 'Julio') and (emp.nested.lname > 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-63.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-63.sqlpp
new file mode 100644
index 0000000..0fa570d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/btree-index/btree-secondary-63.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-63.adm"
+create type test.TestTypetmp as
+{
+  id : int32
+}
+
+create type test.TestType as
+{
+  nested : TestTypetmp
+}
+
+create  table testdst(TestType) primary key nested.id;
+
+create  index sec_Idx  on testdst (nested.fname:string,nested.lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.nested.fname < 'Julio') and (emp.nested.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-contains-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-contains-panic.sqlpp
new file mode 100644
index 0000000..bbfaaaf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-contains-panic.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains-panic.adm"
+select element o
+from  DBLP as o
+where test.contains(o.nested.title,'Mu')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-contains.sqlpp
new file mode 100644
index 0000000..d62e983
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-contains.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
new file mode 100644
index 0000000..740f873
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check-panic.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check.sqlpp
new file mode 100644
index 0000000..154bc8f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm"
+select element o
+from  DBLP as o
+where test."edit-distance-check"(o.nested.authors,'Amihay Motro',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-panic.sqlpp
new file mode 100644
index 0000000..39bc4a5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-panic.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-panic.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.nested.authors,'Amihay Motro') <= 5)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance.sqlpp
new file mode 100644
index 0000000..214cefa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.nested.authors,'Amihay Motro') <= 1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..59347e2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query with ~= using edit-distance on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element o
+from  DBLP as o
+where (o.nested.authors ~= 'Amihay Motro')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..19fb844
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query with ~= using Jaccard on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element o
+from  DBLP as o
+where (test."gram-tokens"(o.nested.title,3,false) ~= test."gram-tokens"('Transactions for Cooperative Environments',3,false))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard-check.sqlpp
new file mode 100644
index 0000000..4ceb420
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard-check.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard.sqlpp
new file mode 100644
index 0000000..cba627f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false)) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-contains.sqlpp
new file mode 100644
index 0000000..37f3e39
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-contains.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..ef5da6c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element o
+from  DBLP as o
+where (test."word-tokens"(o.nested.title) ~= test."word-tokens"('Transactions for Cooperative Environments'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-jaccard-check.sqlpp
new file mode 100644
index 0000000..dcba84e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-jaccard-check.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-jaccard.sqlpp
new file mode 100644
index 0000000..e6bb7d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-basic/word-jaccard.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments')) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp
new file mode 100644
index 0000000..7845d93
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the first can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  eda as test."edit-distance-check"(o.nested.authors,'Amihay Motro',3),
+      edb as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where (eda[0] and edb[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp
new file mode 100644
index 0000000..dc939c1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the second can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  edb as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5),
+      eda as test."edit-distance-check"(o.nested.authors,'Amihay Motro',3)
+where (edb[0] and eda[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
new file mode 100644
index 0000000..9668866
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
new file mode 100644
index 0000000..732c11d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
new file mode 100644
index 0000000..d96fbdf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-substring.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on the substring of the field.
+ *                  Tests that the optimizer rule correctly drills through the substring function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm"
+select element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper
+where test."edit-distance-check"(test.substring(paper.nested.title,0,8),'datbase',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
new file mode 100644
index 0000000..12fb658
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on individual word tokens.
+ *                  Tests that the optimizer rule correctly drills through the word-tokens function and existential query.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm"
+select element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.nested.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..b6bb119
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-let.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..fd2a1bb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."gram-tokens"(paper.nested.title,3,false),
+      query_tokens as test."gram-tokens"('Transactions for Cooperative Environments',3,false),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..0c4929b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-let.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..8164077
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-multi-let.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.nested.title),
+      query_tokens as test."word-tokens"('Transactions for Cooperative Environments'),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.800000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
new file mode 100644
index 0000000..fccb8d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index msgNgramIx  on TweetMessages (nested."message-text":string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm"
+select element {'tweet':{'id':t1.nested.tweetid,'topics':t1.nested."message-text"},'similar-tweets':(
+        select element {'id':t2.nested.tweetid,'topics':t2.nested."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1.nested."message-text",t2.nested."message-text",7)
+        where (sim[0] and (t2.nested.tweetid != t1.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid > test.int64('240'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_01.sqlpp
new file mode 100644
index 0000000..34dd9fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_01.sqlpp
@@ -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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-01.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      CSX as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_02.sqlpp
new file mode 100644
index 0000000..f6447c8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_02.sqlpp
@@ -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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-02.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  CSX as o1,
+      DBLP as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_03.sqlpp
new file mode 100644
index 0000000..58ca48a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-03.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      DBLP as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_04.sqlpp
new file mode 100644
index 0000000..b1a581f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-contains_04.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-04.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      CSX as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..98a552e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_01.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_02.sqlpp
new file mode 100644
index 0000000..6d908cf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_02.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where (test."edit-distance-check"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_03.sqlpp
new file mode 100644
index 0000000..a6b1cd2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_03.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.
+ */
+/*
+ * Description    : Self joins dataset DBLP, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."edit-distance-check"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_04.sqlpp
new file mode 100644
index 0000000..2550577
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_04.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index_DBLP  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_05.sqlpp
new file mode 100644
index 0000000..1688938
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_05.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-contains.sqlpp
new file mode 100644
index 0000000..163f151
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-contains.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-contains function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-contains.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-contains"(a.nested.authors,b.nested.authors,3)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-inline.sqlpp
new file mode 100644
index 0000000..356d816
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-inline.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm"
+select element {'aauthors':a.nested.authors,'bauthors':b.nested.authors,'ed':ed}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance"(a.nested.authors,b.nested.authors)
+where ((ed < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_01.sqlpp
new file mode 100644
index 0000000..429958a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_01.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.nested.authors,b.nested.authors) < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_02.sqlpp
new file mode 100644
index 0000000..b9e2bb9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_02.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where ((test."edit-distance"(a.nested.authors,b.nested.authors) < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_03.sqlpp
new file mode 100644
index 0000000..dc53ff4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_03.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.
+ */
+/*
+ * Description    : Self joins dataset DBLP, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."edit-distance"(a.nested.authors,b.nested.authors) < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_04.sqlpp
new file mode 100644
index 0000000..ac087b7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_04.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index_DBLP  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.nested.authors,b.nested.authors) < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_05.sqlpp
new file mode 100644
index 0000000..28b0bfa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_05.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.nested.authors,b.nested.authors) < 3) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
new file mode 100644
index 0000000..4c6646c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.nested.authors ~= b.nested.authors) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp
new file mode 100644
index 0000000..4f391e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where ((a.nested.authors ~= b.nested.authors) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_03.sqlpp
new file mode 100644
index 0000000..d34082f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_03.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.
+ */
+/*
+ * Description    : Self joins dataset DBLP, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((a.nested.authors ~= b.nested.authors) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_04.sqlpp
new file mode 100644
index 0000000..216aeb2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_04.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index_DBLP  on DBLP (nested.authors:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.nested.authors ~= b.nested.authors) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_05.sqlpp
new file mode 100644
index 0000000..dcb2c4f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_05.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram index on authors, and we *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.nested.authors ~= b.nested.authors) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..ef02155
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.nested.title,3,false) ~= test."gram-tokens"(b.nested.title,3,false)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..bae8d44
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where ((test."gram-tokens"(a.nested.title,3,false) ~= test."gram-tokens"(b.nested.title,3,false)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..6f918a5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp
@@ -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    : Self joins dataset DBLP, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."gram-tokens"(a.nested.title,3,false) ~= test."gram-tokens"(b.nested.title,3,false)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_04.sqlpp
new file mode 100644
index 0000000..42ffaeb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_04.sqlpp
@@ -0,0 +1,76 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index_DBLP  on DBLP (nested.title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.nested.title,3,false) ~= test."gram-tokens"(b.nested.title,3,false)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..7c2d5d8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_01.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..37ff0e0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_02.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..877d872
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_03.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Self joins dataset DBLP, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..ff308a7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_04.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index_DBLP  on DBLP (nested.title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-inline.sqlpp
new file mode 100644
index 0000000..198110f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-inline.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm"
+select element {'atitle':a.nested.title,'btitle':b.nested.title,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_01.sqlpp
new file mode 100644
index 0000000..13e2a0e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_01.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_02.sqlpp
new file mode 100644
index 0000000..90d0380
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_02.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index  on CSX (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_03.sqlpp
new file mode 100644
index 0000000..21ce12f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_03.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Self joins dataset DBLP, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_04.sqlpp
new file mode 100644
index 0000000..d503ef7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_04.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index ngram_index_DBLP  on DBLP (nested.title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (nested.title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..f590056
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.nested.title) ~= test."word-tokens"(b.nested.title)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..b8b1606
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on CSX (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where ((test."word-tokens"(a.nested.title) ~= test."word-tokens"(b.nested.title)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..70393dd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_03.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.
+ */
+/*
+ * Description    : Self joins dataset DBLP, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."word-tokens"(a.nested.title) ~= test."word-tokens"(b.nested.title)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.sqlpp
new file mode 100644
index 0000000..004ebb1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index_DBLP  on DBLP (nested.title:string) type keyword enforced;
+
+create  index keyword_index_CSX  on CSX (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.nested.title) ~= test."word-tokens"(b.nested.title)) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
new file mode 100644
index 0000000..d1861c2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Fuzzy self joins a dataset, TweetMessages, based on the similarity-jaccard-check function of its text-messages' word tokens.
+ *                  TweetMessages has a keyword index on text-message and btree index on the primary key tweetid, and we expect the join to be
+ *					transformed into btree and inverted indexed nested-loop joins. We test whether the join condition can be transformed into
+ *					multiple indexed nested loop joins of various type of indexes.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text":string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm"
+select element {'t1':t1.nested.tweetid,'t2':t2.nested.tweetid,'sim':sim[1]}
+from  TweetMessages as t1,
+      TweetMessages as t2
+with  sim as test."similarity-jaccard-check"(test."word-tokens"(t1.nested."message-text"),test."word-tokens"(t2.nested."message-text"),0.600000f)
+where (sim[0] and (t1.nested.tweetid < test.int64('20')) and (t2.nested.tweetid != t1.nested.tweetid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..8315087
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_01.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..2f1a193
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_02.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on CSX (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..574fa08
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_03.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.
+ */
+/*
+ * Description    : Selg joins dataset DBLP, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index_DBLP  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..c39897a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_04.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+create  index keyword_index  on CSX (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title),0.500000f)[0] and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-inline.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-inline.sqlpp
new file mode 100644
index 0000000..2cea216
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard-inline.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm"
+select element {'atitle':a.nested.title,'btitle':b.nested.title,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_01.sqlpp
new file mode 100644
index 0000000..8db124f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_01.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_02.sqlpp
new file mode 100644
index 0000000..f9bda14
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_02.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on CSX (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  CSX as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_03.sqlpp
new file mode 100644
index 0000000..5bf70fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_03.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.
+ */
+/*
+ * Description    : Self joins dataset DBLP, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_04.sqlpp
new file mode 100644
index 0000000..3a8fb16
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/inverted-index-join/word-jaccard_04.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
+create  index keyword_index  on CSX (nested.title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
new file mode 100644
index 0000000..4068562
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
@@ -0,0 +1,79 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location":point) type rtree enforced;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm"
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.nested."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
new file mode 100644
index 0000000..00f174b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
@@ -0,0 +1,79 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create type test.TweetMessageType as
+{
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location":point) type rtree enforced;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm"
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2.nested."sender-location",n) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp
new file mode 100644
index 0000000..0458c9f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData1(MyRecordNested) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (nested.point) type rtree;
+
+write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp
new file mode 100644
index 0000000..7893c9b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData2' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData1(MyRecordNested) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData2 (point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp
new file mode 100644
index 0000000..35c6196
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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    : Self-joins a dataset on the intersection of its point attribute.
+ *                  The dataset has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData(MyRecordNested) primary key nested.id;
+
+create  index rtree_index  on MyData (nested.point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_03.adm"
+select element {'a':a,'b':b}
+from  MyData as a,
+      MyData as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp
new file mode 100644
index 0000000..fcd5ac4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  Both datasets 'MyData' and 'MyData2' have an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNestedOpen as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordOpen as
+ closed {
+  nested : MyRecordNestedOpen
+}
+
+create  table MyData1(MyRecordOpen) primary key nested.id;
+
+create  table MyData2(MyRecordOpen) primary key nested.id;
+
+create  index rtree_index  on MyData1 (nested.point:point) type rtree enforced;
+
+create  index rtree_index2  on MyData2 (nested.point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp
new file mode 100644
index 0000000..39a7c66
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp
@@ -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    : Joins two datasets on the intersection of their point attributes.
+ *                  Only dataset 'MyData1' has an enforced open RTree index, hence we
+ *                  *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNestedOpen as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordOpen as
+ closed {
+  nested : MyRecordNestedOpen
+}
+
+create  table MyData1(MyRecordOpen) primary key nested.id;
+
+create  table MyData2(MyRecordOpen) primary key nested.id;
+
+create  index rtree_index  on MyData1 (nested.point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp
new file mode 100644
index 0000000..1abe40e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+write output to nc1:"/tmp/nested_loj.adm"
+select element {'cust':c,'orders':orders}
+from  Customers as c
+with  orders as (
+      select element {'order':o,'items':items}
+      from  Orders as o
+      with  items as (
+            select element l
+            from  LineItems as l
+            where (l.l_orderkey = o.o_orderkey)
+        )
+      where (o.o_custkey = c.c_custkey)
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp
new file mode 100644
index 0000000..93c153d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp
@@ -0,0 +1,110 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+create  table PartSupp(PartSuppType) primary key ps_partkey,ps_suppkey on group1;
+
+write output to nc1:"/tmp/nested_loj.adm"
+select element {'cust':c,'orders':orders}
+from  Customers as c
+with  orders as (
+      select element {'order':o,'items':items}
+      from  Orders as o
+      with  items as (
+            select element {'item':l,'part_supplier':partsupp}
+            from  LineItems as l
+            with  partsupp as (
+                  select element ps
+                  from  PartSupp as ps
+                  where ((ps.ps_partkey = l.l_partkey) and (ps.ps_suppkey = l.l_suppkey))
+              )
+            where (l.l_orderkey = o.o_orderkey)
+        )
+      where (o.o_custkey = c.c_custkey)
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp
new file mode 100644
index 0000000..3e78b25
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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    : Disjunctive predicate should be transformed into collection scan.
+ *                  Secondary index should be used to probe the values retrieved from collection.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : string,
+  "no-idx" : string
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (idx:string) type btree enforced;
+
+select element x
+from  TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
new file mode 100644
index 0000000..f3b1479
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
new file mode 100644
index 0000000..60e721e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountAIx  on TweetMessages (countA:int32) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
new file mode 100644
index 0000000..148a4f4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
new file mode 100644
index 0000000..ab89fab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountAIx  on TweetMessages (countA:int32) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp
new file mode 100644
index 0000000..5533e0a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp
new file mode 100644
index 0000000..0381eb5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp
new file mode 100644
index 0000000..ea10df7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
new file mode 100644
index 0000000..06c22a3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
new file mode 100644
index 0000000..7e113f4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
new file mode 100644
index 0000000..cc1809f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
new file mode 100644
index 0000000..8513c6b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_04.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
new file mode 100644
index 0000000..c3aaad7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_05.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
new file mode 100644
index 0000000..0c6b8a3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
@@ -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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_06.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp
new file mode 100644
index 0000000..97117f6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
+ *                  We first expect FacebookUsers' primary index to be used
+ *                  to satisfy the range condition on it's primary key.
+ *                  FacebookMessages has a secondary btree open index on author-id-copy, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserType as
+ closed {
+  id : int32,
+  "id-copy" : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int32}},
+  employment : [EmploymentType]
+}
+
+create type test.FacebookMessageType as
+{
+  "message-id" : int32,
+  "message-id-copy" : int32,
+  "author-id" : int32,
+  "in-response-to" : int32?,
+  "sender-location" : point?,
+  message : string
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  index fbmIdxAutId  if not exists  on FacebookMessages ("author-id-copy":int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm"
+select element {'fbu-ID':user.id,'fbm-auth-ID':message."author-id",'uname':user.name,'message':message.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where ((user.id /*+ indexnl */  = message."author-id-copy") and (user.id >= 11000) and (user.id <= 12000))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..a24c904
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the additional predicates to be put into a select above the
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multipred.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.title /*+ indexnl */  = b.title) and (a.authors < b.authors) and (a.misc > b.misc))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp
new file mode 100644
index 0000000..370dfb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp
new file mode 100644
index 0000000..091c7ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  CSX has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on CSX (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp
new file mode 100644
index 0000000..dd0e8a2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Equi self-joins a dataset, DBLP, based on its title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp
new file mode 100644
index 0000000..25ad745
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  Both DBLP and CSX have secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index_DBLP  on DBLP (title:string) type btree enforced;
+
+create  index title_index  on CSX (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp
new file mode 100644
index 0000000..d4e7952
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we *do not* expect the join to be transformed into an indexed nested-loop join,
+ *                  because CSX does not declare an enforced open index on field title.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp
new file mode 100644
index 0000000..7db87d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Roger')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp
new file mode 100644
index 0000000..9241ab4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-32.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Susan')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp
new file mode 100644
index 0000000..d957ed4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp
@@ -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     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-33.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Isa')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp
new file mode 100644
index 0000000..62f8eed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-34.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Vanpatten')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp
new file mode 100644
index 0000000..12ab41f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-35.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname != 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp
new file mode 100644
index 0000000..4b04e48
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-36.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname = 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-39.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-39.sqlpp
new file mode 100644
index 0000000..de76f42
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-39.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-37.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.lname = 'Kim')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-40.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-40.sqlpp
new file mode 100644
index 0000000..93a7d0a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-40.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-38.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Young Seok') and (emp.lname = 'Kim'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-41.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-41.sqlpp
new file mode 100644
index 0000000..4fabbcc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-41.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-39.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') or (emp.lname = 'Malaika'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-42.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-42.sqlpp
new file mode 100644
index 0000000..57133c9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-42.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-40.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Alex') and (emp.lname < 'Zach'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-43.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-43.sqlpp
new file mode 100644
index 0000000..ea39a03
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-43.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-41.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Allan') and (emp.lname < 'Zubi'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-44.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-44.sqlpp
new file mode 100644
index 0000000..6845569
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-44.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-42.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Allan') and (emp.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-45.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-45.sqlpp
new file mode 100644
index 0000000..a574bf3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-45.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-43.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') and (emp.lname < 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-46.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-46.sqlpp
new file mode 100644
index 0000000..706afd7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-46.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-44.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Michael') and (emp.lname <= 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-47.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-47.sqlpp
new file mode 100644
index 0000000..878e264
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-47.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-45.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-48.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-48.sqlpp
new file mode 100644
index 0000000..11562fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-48.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-46.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname >= 'Kevin') and (emp.fname <= 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-49.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-49.sqlpp
new file mode 100644
index 0000000..ea4f4fe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-49.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-47.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname <= 'Craig') and (emp.lname > 'Kevin'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-50.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-50.sqlpp
new file mode 100644
index 0000000..1a1c090
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-50.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-48.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname != 'Michael') and (emp.lname != 'Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-51.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-51.sqlpp
new file mode 100644
index 0000000..a1f1135
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-51.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname <= 'Mary') and (emp.lname <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-52.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-52.sqlpp
new file mode 100644
index 0000000..fa3f16e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-52.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-50.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname >= 'Kevin') and (emp.fname < 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-53.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-53.sqlpp
new file mode 100644
index 0000000..1c5656b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-53.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-51.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Craig') and (emp.lname <= 'Kevin') and (emp.fname <= 'Mary') and (emp.lname >= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-54.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-54.sqlpp
new file mode 100644
index 0000000..4c764fe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-54.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-52.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-55.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-55.sqlpp
new file mode 100644
index 0000000..5d2bd3f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-55.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-53.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Sofia')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-56.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-56.sqlpp
new file mode 100644
index 0000000..b4d8ca6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-56.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-54.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Chen')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-57.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-57.sqlpp
new file mode 100644
index 0000000..d247975
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-57.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-55.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Julio')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-58.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-58.sqlpp
new file mode 100644
index 0000000..062cd2d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-58.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-56.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Neil') and (emp.fname < 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-59.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-59.sqlpp
new file mode 100644
index 0000000..c6cfbdd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-59.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname >= 'Max') and (emp.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-60.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-60.sqlpp
new file mode 100644
index 0000000..cf717f8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-60.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-58.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname = 'Max')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-61.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-61.sqlpp
new file mode 100644
index 0000000..05fedeb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-61.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname > 'Craig') and (emp.lname > 'Kevin') and (emp.fname <= 'Mary') and (emp.lname < 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-62.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-62.sqlpp
new file mode 100644
index 0000000..8b1ca74
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-62.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-62.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname = 'Julio') and (emp.lname > 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-63.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-63.sqlpp
new file mode 100644
index 0000000..582f8a7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-63.sqlpp
@@ -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     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-63.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where ((emp.fname < 'Julio') and (emp.lname = 'Xu'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains-panic.sqlpp
new file mode 100644
index 0000000..7245e87
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains-panic.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains-panic.adm"
+select element o
+from  DBLP as o
+where test.contains(o.title,'Mu')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains.sqlpp
new file mode 100644
index 0000000..ba79dc4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
new file mode 100644
index 0000000..275b63d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.sqlpp
new file mode 100644
index 0000000..0802881
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm"
+select element o
+from  DBLP as o
+where test."edit-distance-check"(o.authors,'Amihay Motro',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.sqlpp
new file mode 100644
index 0000000..93ef239
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-panic.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Amihay Motro') <= 5)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance.sqlpp
new file mode 100644
index 0000000..0bdf6d1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Amihay Motro') <= 1)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp
new file mode 100644
index 0000000..be662b1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query with ~= using edit-distance on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element o
+from  DBLP as o
+where (o.authors ~= 'Amihay Motro')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..59a4489
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query with ~= using Jaccard on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element o
+from  DBLP as o
+where (test."gram-tokens"(o.title,3,false) ~= test."gram-tokens"('Transactions for Cooperative Environments',3,false))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard-check.sqlpp
new file mode 100644
index 0000000..78c7f4b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard-check.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard.sqlpp
new file mode 100644
index 0000000..db169b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false)) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-contains.sqlpp
new file mode 100644
index 0000000..d1da134
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-contains.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-contains.adm"
+select element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp
new file mode 100644
index 0000000..210f38f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element o
+from  DBLP as o
+where (test."word-tokens"(o.title) ~= test."word-tokens"('Transactions for Cooperative Environments'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard-check.sqlpp
new file mode 100644
index 0000000..bc3b644
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard-check.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard-check.adm"
+select element o
+from  DBLP as o
+where test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard.sqlpp
new file mode 100644
index 0000000..93c9882
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard.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.
+ */
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm"
+select element o
+from  DBLP as o
+where (test."similarity-jaccard"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments')) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp
new file mode 100644
index 0000000..b0a7e95
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the first can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  eda as test."edit-distance-check"(o.authors,'Amihay Motro',3),
+      edb as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where (eda[0] and edb[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp
new file mode 100644
index 0000000..63752f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the second can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"
+select element o
+from  DBLP as o
+with  edb as test."edit-distance-check"(o.authors,'Amihay Motro',5),
+      eda as test."edit-distance-check"(o.authors,'Amihay Motro',3)
+where (edb[0] and eda[0])
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
new file mode 100644
index 0000000..3a4f02e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
new file mode 100644
index 0000000..f76aa93
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let.adm"
+select element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
new file mode 100644
index 0000000..cdbcbc5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on the substring of the field.
+ *                  Tests that the optimizer rule correctly drills through the substring function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm"
+select element {'id':paper.id,'title':paper.title}
+from  DBLP as paper
+where test."edit-distance-check"(test.substring(paper.title,0,8),'datbase',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
new file mode 100644
index 0000000..d1f8bf0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on individual word tokens.
+ *                  Tests that the optimizer rule correctly drills through the word-tokens function and existential query.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm"
+select element {'id':paper.id,'title':paper.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..2faf06a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..9a7ea07
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.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.
+ */
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."gram-tokens"(paper.title,3,false),
+      query_tokens as test."gram-tokens"('Transactions for Cooperative Environments',3,false),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-let.sqlpp
new file mode 100644
index 0000000..05b253e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-let.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-let.adm"
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.sqlpp
new file mode 100644
index 0000000..0796a6a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-multi-let.adm"
+select element {'Paper':paper_tokens,'Query':query_tokens}
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Transactions for Cooperative Environments'),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.800000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
new file mode 100644
index 0000000..549959d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgNgramIx  on TweetMessages ("message-text":string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm"
+select element {'tweet':{'id':t1.tweetid,'topics':t1."message-text"},'similar-tweets':(
+        select element {'id':t2.tweetid,'topics':t2."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1."message-text",t2."message-text",7)
+        where (sim[0] and (t2.tweetid != t1.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_01.sqlpp
new file mode 100644
index 0000000..34dd9fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_01.sqlpp
@@ -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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-01.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      CSX as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_02.sqlpp
new file mode 100644
index 0000000..bbccf5e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_02.sqlpp
@@ -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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-02.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      CSX as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_03.sqlpp
new file mode 100644
index 0000000..58ca48a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-03.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      DBLP as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_04.sqlpp
new file mode 100644
index 0000000..b1a581f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_04.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Tests whether an ngram_index is applied to optimize a join query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-contains-04.adm"
+select element {'title1':o1.title,'title2':o2.title}
+from  DBLP as o1,
+      CSX as o2
+where (test.contains(o1.title,o2.title) and (o1.id < o2.id))
+order by o1.id,o2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..aad6109
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_01.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_02.sqlpp
new file mode 100644
index 0000000..cdce39b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_02.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  CSX has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_03.sqlpp
new file mode 100644
index 0000000..2f9643b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_03.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance-check function of its authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_04.sqlpp
new file mode 100644
index 0000000..8d9cc00
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_04.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP and CSX both have a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (authors:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_05.sqlpp
new file mode 100644
index 0000000..2ebf73a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_05.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-check function of their authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we *do not* expect the join to be transformed
+ *                  into an indexed nested-loop join, because CSX does not declare an enforced open index on field authors.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-check"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_inline_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_inline_03.sqlpp
new file mode 100644
index 0000000..27e9de2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_inline_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance-check function of its authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-check_04.adm"
+select element {'arec':a,'brec':b,'ed':ed[1]}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance-check"(a.authors,b.authors,3)
+where (ed[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-contains.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-contains.sqlpp
new file mode 100644
index 0000000..ce38c41
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-contains.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance-contains function of their authors.
+ *                  DBLP has a 3-gram index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-contains.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."edit-distance-contains"(a.authors,b.authors,3)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_01.sqlpp
new file mode 100644
index 0000000..d488fae
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_01.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_02.sqlpp
new file mode 100644
index 0000000..0078883
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_02.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  CSX has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_03.sqlpp
new file mode 100644
index 0000000..d1bd58b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_03.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_04.sqlpp
new file mode 100644
index 0000000..8f4f23e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_04.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP and CSX both have a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (authors:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_05.sqlpp
new file mode 100644
index 0000000..c992c27
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_05.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the edit-distance function of their authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we *do not* expect the join to be transformed
+ *                  into an indexed nested-loop join, because CSX does not declare an enforced open index on field authors.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."edit-distance"(a.authors,b.authors) < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_inline_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_inline_03.sqlpp
new file mode 100644
index 0000000..8a1d662
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_inline_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the edit-distance function of its authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-edit-distance_03.adm"
+select element {'arec':a,'brec':b,'ed':ed}
+from  DBLP as a,
+      DBLP as b
+with  ed as test."edit-distance"(a.authors,b.authors)
+where ((ed < 3) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
new file mode 100644
index 0000000..780cdd0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp
new file mode 100644
index 0000000..e456889
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  CSX has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_03.sqlpp
new file mode 100644
index 0000000..3151d92
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_03.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on ~= using edit distance of its authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_03.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_04.sqlpp
new file mode 100644
index 0000000..eb3a137
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_04.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP and CSX both have a 3-gram enforced open index on authors, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (authors:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_05.sqlpp
new file mode 100644
index 0000000..002c5d5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_05.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using edit distance of their authors.
+ *                  DBLP has a 3-gram enforced open index on authors, and we *do not* expect the join to be transformed
+ *                  into an indexed nested-loop join, because CSX does not declare an enforced open index on field authors.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  title : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (authors:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.authors ~= b.authors) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..79012f3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy joins two datasets, open DBLP and closed CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..dadeb9d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy joins two datasets, closed DBLP and open CSX, based on ~= using Jaccard their titles' 3-gram tokens.
+ *                  CSX has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_02.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..a3d8a69
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_03.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on ~= using Jaccard of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_03.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_04.sqlpp
new file mode 100644
index 0000000..441e382
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_04.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' 3-gram tokens.
+ *                  DBLP and CSX both have a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."gram-tokens"(a.title,3,false) ~= test."gram-tokens"(b.title,3,false)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..67e43d5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_01.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy joins two datasets, open DBLP and closed CSX, based on the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..dfd8194
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_02.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy joins two datasets, closed DBLP and open CSX, based the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  CSX has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..526fb3a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Fuzzy self joins an open dataset DBLP, based on the similarity-jaccard-check function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..2b06b29
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_04.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based the similarity-jaccard-check function of their titles' 3-gram tokens.
+ *                  DBLP and CSX both have a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_inline_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_inline_03.sqlpp
new file mode 100644
index 0000000..a085a61
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_inline_03.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard-check_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc[1]}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false),0.500000f)
+where (jacc[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_01.sqlpp
new file mode 100644
index 0000000..1c681ec
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_01.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_02.sqlpp
new file mode 100644
index 0000000..e4db9e6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_02.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  CSX has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_03.sqlpp
new file mode 100644
index 0000000..d57a38b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_04.sqlpp
new file mode 100644
index 0000000..59f521e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_04.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP and CSX both have a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index ngram_index_DBLP  on DBLP (title:string) type ngram (3) enforced;
+
+create  index ngram_index_CSX  on CSX (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_inline_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_inline_03.sqlpp
new file mode 100644
index 0000000..7cc9969
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_inline_03.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
+ *                  DBLP has a 3-gram enforced open index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+set "import-private-functions" "true";
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_ngram-jaccard_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
new file mode 100644
index 0000000..4e35c80
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_01.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp
new file mode 100644
index 0000000..a33e9d0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_02.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  CSX has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on CSX (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_02.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_03.sqlpp
new file mode 100644
index 0000000..9f09553
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_03.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.
+ */
+/*
+ * Description    : Fuzzy self joins a dataset, DBLP, based on ~= using Jaccard of its titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_03.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.sqlpp
new file mode 100644
index 0000000..6816885
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on ~= using Jaccard of their titles' word tokens.
+ *                  DBLP and CSX both have an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index_DBLP  on DBLP (title:string) type keyword enforced;
+
+create  index keyword_index_CSX  on CSX (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."word-tokens"(a.title) ~= test."word-tokens"(b.title)) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
new file mode 100644
index 0000000..5620d1a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check-after-btree-access.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy self joins a dataset, TweetMessages, based on the similarity-jaccard-check function of its text-messages' word tokens.
+ *                  TweetMessages has a keyword index on text-message and btree index on the primary key tweetid, and we expect the join to be
+ *					transformed into btree and inverted indexed nested-loop joins. We test whether the join condition can be transformed into
+ *					multiple indexed nested loop joins of various type of indexes.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text":string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm"
+select element {'t1':t1.tweetid,'t2':t2.tweetid,'sim':sim[1]}
+from  TweetMessages as t1,
+      TweetMessages as t2
+with  sim as test."similarity-jaccard-check"(test."word-tokens"(t1."message-text"),test."word-tokens"(t2."message-text"),0.600000f)
+where (sim[0] and (t1.tweetid < test.int64('20')) and (t2.tweetid != t1.tweetid))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..b4df5ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_01.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..54576d9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_02.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  CSX has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on CSX (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..e6b89bf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_03.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..c911894
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_04.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard-check function of their titles' word tokens.
+ *                  DBLP and CSX both have an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index_DBLP  on DBLP (title:string) type keyword enforced;
+
+create  index keyword_index_CSX  on CSX (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_inline_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_inline_03.sqlpp
new file mode 100644
index 0000000..ad51a9d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_inline_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard-check function of its titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard-check_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc[1]}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(a.title),test."word-tokens"(b.title),0.500000f)
+where (jacc[0] and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_01.sqlpp
new file mode 100644
index 0000000..c59290b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_01.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_02.sqlpp
new file mode 100644
index 0000000..21a1b75
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_02.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  CSX has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index  on CSX (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_03.sqlpp
new file mode 100644
index 0000000..597d60c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_03.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_04.sqlpp
new file mode 100644
index 0000000..8bfbcc1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_04.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP and CSX both have an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index keyword_index_DBLP  on DBLP (title:string) type keyword enforced;
+
+create  index keyword_index_CSX  on CSX (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_inline_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_inline_03.sqlpp
new file mode 100644
index 0000000..c1cd43d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_inline_03.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' word tokens.
+ *                  DBLP has an enforced open keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-join_word-jaccard_04.adm"
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLP as a,
+      DBLP as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
new file mode 100644
index 0000000..0df4508
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location":point) type rtree enforced;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
new file mode 100644
index 0000000..09a8e9d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location":point) type rtree enforced;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2."sender-location",n) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_01.sqlpp
new file mode 100644
index 0000000..853cbcc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_01.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData1(MyRecordOpen) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (point:point) type rtree enforced;
+
+write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_02.sqlpp
new file mode 100644
index 0000000..d6aaacb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_02.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData2' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData1(MyRecord) primary key id;
+
+create  table MyData2(MyRecordOpen) primary key id;
+
+create  index rtree_index  on MyData2 (point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_03.sqlpp
new file mode 100644
index 0000000..7a0ff8a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_03.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.
+ */
+/*
+ * Description    : Self-joins a dataset on the intersection of its point attribute.
+ *                  The dataset has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  index rtree_index  on MyData (point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_03.adm"
+select element {'a':a,'b':b}
+from  MyData as a,
+      MyData as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_04.sqlpp
new file mode 100644
index 0000000..051e695
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_04.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  Both datasets 'MyData' and 'MyData2' have an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData1(MyRecord) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (point:point) type rtree enforced;
+
+create  index rtree_index2  on MyData2 (point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_05.sqlpp
new file mode 100644
index 0000000..01015ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_05.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  Only dataset 'MyData1' has an enforced open RTree index, hence we
+ *                  *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData1(MyRecord) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orderby-desc-using-gby.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orderby-desc-using-gby.sqlpp
new file mode 100644
index 0000000..34a82ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orderby-desc-using-gby.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.
+ */
+
+drop  database "gby-using-orderby-desc" if exists;
+create  database "gby-using-orderby-desc";
+
+use "gby-using-orderby-desc";
+
+
+create type "gby-using-orderby-desc".AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type "gby-using-orderby-desc".CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
+write output to nc1:"rttest/gby-using-orderby-desc.adm"
+select element {'name':name,'age':age}
+from  Customers as c
+group by c.name as name
+order by name desc,age
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-aggreg.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-aggreg.sqlpp
new file mode 100644
index 0000000..4835a59
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-aggreg.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 "orders-aggreg" if exists;
+create  database "orders-aggreg";
+
+use "orders-aggreg";
+
+
+create type "orders-aggreg".OrderType as
+ closed {
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key oid on group1;
+
+write output to nc1:"/tmp/orders-aggreg.adm"
+select element {'cid':cid,'ordpercust':"orders-aggreg".count(o),'totalcust':"orders-aggreg".sum((
+        select element i.total
+        from  o as i
+    )),'avgcust':"orders-aggreg".avg((
+        select element i.total
+        from  o as i
+    ))}
+from  Orders as o
+group by o.cid as cid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-composite-index-search.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-composite-index-search.sqlpp
new file mode 100644
index 0000000..c8efddd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-composite-index-search.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.
+ */
+
+drop  database index_search if exists;
+create  database index_search;
+
+use index_search;
+
+
+create type index_search.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  index idx_Custkey_Orderstatus  on Orders (o_custkey,o_orderstatus) type btree;
+
+write output to nc1:"/tmp/index_search.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey,'o_orderstatus':o.o_orderstatus}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_orderstatus = 'P'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive-open_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive-open_01.sqlpp
new file mode 100644
index 0000000..faba2ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive-open_01.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+{
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
+write output to nc1:"/tmp/index_search-conjunctive.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive-open_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive-open_02.sqlpp
new file mode 100644
index 0000000..90c5a52
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive-open_02.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+{
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
+write output to nc1:"/tmp/index_search-conjunctive.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey,'o_totalprice':o.o_totalprice}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive_01.sqlpp
new file mode 100644
index 0000000..0b06385
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive_01.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
+write output to nc1:"/tmp/index_search-conjunctive.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive_02.sqlpp
new file mode 100644
index 0000000..62c3577
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-conjunctive_02.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
+write output to nc1:"/tmp/index_search-conjunctive.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey,'o_totalprice':o.o_totalprice}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-open.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-open.sqlpp
new file mode 100644
index 0000000..eae957f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search-open.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 index_search if exists;
+create  database index_search;
+
+use index_search;
+
+
+create type index_search.OrderType as
+{
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
+write output to nc1:"/tmp/index_search.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where (o.o_custkey = 40)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search.sqlpp
new file mode 100644
index 0000000..a70f0ba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/orders-index-search.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 index_search if exists;
+create  database index_search;
+
+use index_search;
+
+
+create type index_search.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
+write output to nc1:"/tmp/index_search.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where (o.o_custkey = 40)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/prim-idx-search-open.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/prim-idx-search-open.sqlpp
new file mode 100644
index 0000000..8653b01
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/prim-idx-search-open.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 prim_index_search if exists;
+create  database prim_index_search;
+
+use prim_index_search;
+
+
+create type prim_index_search.OrderType as
+{
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+write output to nc1:"/tmp/prim_index_search.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where (o.o_orderkey = 34)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/prim-idx-search.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/prim-idx-search.sqlpp
new file mode 100644
index 0000000..1bf0d81
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/prim-idx-search.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 prim_index_search if exists;
+create  database prim_index_search;
+
+use prim_index_search;
+
+
+create type prim_index_search.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+write output to nc1:"/tmp/prim_index_search.adm"
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where (o.o_orderkey = 34)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/pull_select_above_eq_join.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/pull_select_above_eq_join.sqlpp
new file mode 100644
index 0000000..2820784
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/pull_select_above_eq_join.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 "pull-select-above-eq-join" if exists;
+create  database "pull-select-above-eq-join";
+
+use "pull-select-above-eq-join";
+
+
+create type "pull-select-above-eq-join".UserType as
+{
+  uid : int32,
+  name : string,
+  city : string,
+  lottery_numbers : {{int32}}
+}
+
+create type "pull-select-above-eq-join".VisitorType as
+{
+  vid : int32,
+  name : string,
+  city : string,
+  lottery_numbers : {{int32}}
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Users(UserType) primary key uid on group1;
+
+create  table Visitors(VisitorType) primary key vid on group1;
+
+write output to nc1:"/tmp/pull-select-above-eq-join.adm"
+select element {'uid':user.uid,'vid':visitor.vid}
+from  Users as user,
+      Visitors as visitor
+where ((user.name = visitor.name) and (user.city != visitor.city))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/push-project-through-group.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/push-project-through-group.sqlpp
new file mode 100644
index 0000000..7516412
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/push-project-through-group.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 fuzzyjoin_080 if exists;
+create  database fuzzyjoin_080;
+
+use fuzzyjoin_080;
+
+
+create type fuzzyjoin_080.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+write output to nc1:"rttest/fuzzyjoin_080.adm"
+select element {'id':paperDBLP.id,'matches':matches}
+from  DBLP as paperDBLP
+with  matches as (
+      select element paper.title
+      from  DBLP as paper
+      where (paper.authors = paperDBLP.authors)
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/push_limit.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/push_limit.sqlpp
new file mode 100644
index 0000000..72b382f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/push_limit.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+write output to nc1:"/tmp/push_limit.adm"
+select element {'price':o.o_totalprice,'date':o.o_orderdate}
+from  Orders as o
+where (o.o_totalprice > 100)
+order by o.o_orderkey
+limit 10 offset 5
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q01_pricing_summary_report_nt.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q01_pricing_summary_report_nt.sqlpp
new file mode 100644
index 0000000..d31815a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q01_pricing_summary_report_nt.sqlpp
@@ -0,0 +1,78 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+write output to nc1:"rttest/tpch_q1_pricing_summary_report_nt.adm"
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':tpch.sum((
+        select element i.l_quantity
+        from  l as i
+    )),'sum_base_price':tpch.sum((
+        select element i.l_extendedprice
+        from  l as i
+    )),'sum_disc_price':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount))
+        from  l as i
+    )),'sum_charge':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+        from  l as i
+    )),'ave_qty':tpch.avg((
+        select element i.l_quantity
+        from  l as i
+    )),'ave_price':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'ave_disc':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'count_order':tpch.count(l)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q03_shipping_priority.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q03_shipping_priority.sqlpp
new file mode 100644
index 0000000..6cc87f8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q03_shipping_priority.sqlpp
@@ -0,0 +1,95 @@
+/*
+ * 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 q3_shipping_priority if exists;
+create  database q3_shipping_priority;
+
+use q3_shipping_priority;
+
+
+create type q3_shipping_priority.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type q3_shipping_priority.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type q3_shipping_priority.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+write output to nc1:"/tmp/q3_shipping_priority.adm"
+select element {'l_orderkey':l_orderkey,'revenue':revenue,'o_orderdate':o_orderdate,'o_shippriority':o_shippriority}
+from  Customers as c,
+      Orders as o,
+      LineItems as l
+where (((c.c_mktsegment = 'BUILDING') and (c.c_custkey = o.o_custkey)) and ((l.l_orderkey = o.o_orderkey) and (o.o_orderdate < '1995-03-15') and (l.l_shipdate > '1995-03-15')))
+/* +hash */
+group by l.l_orderkey as l_orderkey,o.o_orderdate as o_orderdate,o.o_shippriority as o_shippriority
+with  revenue as q3_shipping_priority.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  ))
+order by revenue desc,o_orderdate
+limit 10
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q05_local_supplier_volume.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q05_local_supplier_volume.sqlpp
new file mode 100644
index 0000000..a18e7a9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q05_local_supplier_volume.sqlpp
@@ -0,0 +1,145 @@
+/*
+ * 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 q5_local_supplier if exists;
+create  database q5_local_supplier;
+
+use q5_local_supplier;
+
+
+create type q5_local_supplier.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type q5_local_supplier.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type q5_local_supplier.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type q5_local_supplier.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type q5_local_supplier.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type q5_local_supplier.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+create  table Suppliers(SupplierType) primary key s_suppkey on group1;
+
+create  table Nations(NationType) primary key n_nationkey on group1;
+
+create  table Regions(RegionType) primary key r_regionkey on group1;
+
+write output to nc1:"/tmp/q5_local_supplier.adm"
+select element {'n_name':n_name,'revenue':revenue}
+from  Customers as c,
+      (
+    select element {'n_name':l1.n_name,'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'s_nationkey':l1.s_nationkey,'o_custkey':o.o_custkey}
+    from  Orders as o,
+          (
+        select element {'n_name':s1.n_name,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_orderkey':l.l_orderkey,'s_nationkey':s1.s_nationkey}
+        from  LineItems as l,
+              (
+            select element {'n_name':n1.n_name,'s_suppkey':s.s_suppkey,'s_nationkey':s.s_nationkey}
+            from  Suppliers as s,
+                  (
+                select element {'n_name':n.n_name,'n_nationkey':n.n_nationkey}
+                from  Nations as n,
+                      Regions as r
+                where ((n.n_regionkey = r.r_regionkey) and (r.r_name = 'ASIA'))
+            ) as n1
+            where (s.s_nationkey = n1.n_nationkey)
+        ) as s1
+        where (l.l_suppkey = s1.s_suppkey)
+    ) as l1
+    where ((l1.l_orderkey = o.o_orderkey) and (o.o_orderdate >= '1994-01-01') and (o.o_orderdate < '1995-01-01'))
+) as o1
+where ((c.c_nationkey = o1.s_nationkey) and (c.c_custkey = o1.o_custkey))
+/* +hash */
+group by o1.n_name as n_name
+with  revenue as q5_local_supplier.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  o1 as i
+  ))
+order by revenue desc
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q08_group_by.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q08_group_by.sqlpp
new file mode 100644
index 0000000..0c59c3c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q08_group_by.sqlpp
@@ -0,0 +1,153 @@
+/*
+ * 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 q08_group_by if exists;
+create  database q08_group_by;
+
+use q08_group_by;
+
+
+create type q08_group_by.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type q08_group_by.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type q08_group_by.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type q08_group_by.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type q08_group_by.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type q08_group_by.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type q08_group_by.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+select element {'o_orderdate':lnrcop.o_orderdate,'l_discount':lnrcop.l_discount,'l_extendedprice':lnrcop.l_extendedprice,'l_suppkey':lnrcop.l_suppkey,'s_nationkey':s.s_nationkey}
+from  Supplier as s,
+      (
+    select element {'o_orderdate':lnrco.o_orderdate,'l_discount':lnrco.l_discount,'l_extendedprice':lnrco.l_extendedprice,'l_suppkey':lnrco.l_suppkey}
+    from  (
+        select element {'o_orderdate':nrco.o_orderdate,'l_partkey':l.l_partkey,'l_discount':l.l_discount,'l_extendedprice':l.l_extendedprice,'l_suppkey':l.l_suppkey}
+        from  LineItem as l,
+              (
+            select element {'o_orderdate':o.o_orderdate,'o_orderkey':o.o_orderkey}
+            from  Orders as o,
+                  (
+                select element {'c_custkey':c.c_custkey}
+                from  Customer as c,
+                      (
+                    select element {'n_nationkey':n1.n_nationkey}
+                    from  Nation as n1,
+                          Region as r1
+                    where ((n1.n_regionkey = r1.r_regionkey) and (r1.r_name = 'AMERICA'))
+                ) as nr
+                where (c.c_nationkey = nr.n_nationkey)
+            ) as nrc
+            where (nrc.c_custkey = o.o_custkey)
+        ) as nrco
+        where ((l.l_orderkey = nrco.o_orderkey) and (nrco.o_orderdate >= '1995-01-01') and (nrco.o_orderdate <= '1996-12-31'))
+    ) as lnrco,
+          Part as p
+    where ((p.p_partkey = lnrco.l_partkey) and (p.p_type = 'ECONOMY ANODIZED STEEL'))
+) as lnrcop
+where (s.s_suppkey = lnrcop.l_suppkey)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q09_group_by.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q09_group_by.sqlpp
new file mode 100644
index 0000000..e0d1ac2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q09_group_by.sqlpp
@@ -0,0 +1,154 @@
+/*
+ * 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 q09_group_by if exists;
+create  database q09_group_by;
+
+use q09_group_by;
+
+
+create type q09_group_by.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type q09_group_by.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type q09_group_by.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type q09_group_by.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type q09_group_by.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type q09_group_by.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type q09_group_by.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type q09_group_by.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+select element {'l_extendedprice':l2.l_extendedprice,'l_discount':l2.l_discount,'l_quantity':l2.l_quantity,'l_orderkey':l2.l_orderkey,'n_name':l2.n_name,'ps_supplycost':l2.ps_supplycost}
+from  Part as p,
+      (
+    select element {'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'l_quantity':l1.l_quantity,'l_partkey':l1.l_partkey,'l_orderkey':l1.l_orderkey,'n_name':l1.n_name,'ps_supplycost':ps.ps_supplycost}
+    from  Partsupp as ps,
+          (
+        select element {'l_suppkey':l.l_suppkey,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_quantity':l.l_quantity,'l_partkey':l.l_partkey,'l_orderkey':l.l_orderkey,'n_name':s1.n_name}
+        from  (
+            select element {'s_suppkey':s.s_suppkey,'n_name':n.n_name}
+            from  Supplier as s,
+                  Nation as n
+            where (n.n_nationkey = s.s_nationkey)
+        ) as s1,
+              LineItem as l
+        where (s1.s_suppkey = l.l_suppkey)
+    ) as l1
+    where ((ps.ps_suppkey = l1.l_suppkey) and (ps.ps_partkey = l1.l_partkey))
+) as l2
+where (q09_group_by.contains(p.p_name,'green') and (p.p_partkey = l2.l_partkey))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q1.sqlpp
new file mode 100644
index 0000000..cb0f2d9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q1.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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 events if exists;
+create  database events;
+
+use events;
+
+
+create type events.AddressType as
+ closed {
+  street : string,
+  city : string,
+  zip : string,
+  latlong : point
+}
+
+create type events.UserType as
+{
+  name : string,
+  email : string,
+  interests : {{string}},
+  address : AddressType,
+  member_of : {{{
+          sig_name : string,
+          chapter_name : string,
+          member_since : date
+      }
+}}
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table User(UserType) primary key name on group1;
+
+write output to nc1:"/tmp/q1.adm"
+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/optimizerts/queries_sqlpp/q2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q2.sqlpp
new file mode 100644
index 0000000..162dd74
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/q2.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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 events if exists;
+create  database events;
+
+use events;
+
+
+create type events.AddressType as
+ closed {
+  street : string,
+  city : string,
+  zip : string
+}
+
+create type events.EventType as
+ closed {
+  name : string,
+  location : AddressType?,
+  organizers : {{{
+          name : string,
+          role : string
+      }
+}},
+  sponsoring_sigs : [{
+          sig_name : string,
+          chapter_name : string
+      }
+],
+  interest_keywords : {{string}},
+  price : double?,
+  start_time : datetime,
+  end_time : datetime
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Event(EventType) primary key name on group1;
+
+write output to nc1:"/tmp/q2.adm"
+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 events.count(es),
+      by_chapter as (
+      select element {'chapter_name':chapter_name,'escount':events.count(e)}
+      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/optimizerts/queries_sqlpp/query-issue550.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue550.sqlpp
new file mode 100644
index 0000000..33c7947
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue550.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue550
+ * https://code.google.com/p/asterixdb/issues/detail?id=550
+ * Expected Result : Success
+ * Date            : 25th October 2014
+ */
+
+with  sample as {{{'r':1,'uid':'1a2b','t':datetime('2000-01-01T01:00:00'),'event':'e1'},{'r':2,'uid':'1a2b','t':datetime('2000-01-01T01:01:00'),'event':'e2'},{'r':3,'uid':'3c4d','t':datetime('2000-01-01T01:02:00'),'event':'e1'},{'r':4,'uid':'3c4d','t':datetime('2000-01-01T01:03:00'),'event':'e3'},{'r':5,'uid':'1a2b','t':datetime('2000-01-01T01:04:00'),'event':'e1'},{'r':6,'uid':'1a2b','t':datetime('2000-01-01T01:05:00'),'event':'e4'}}}
+select element {'u':u,'recs':(
+        select element srec
+        from  s as srec
+    )}
+from  sample as s
+group by s.uid as u
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue562.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue562.sqlpp
new file mode 100644
index 0000000..5fb9440
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue562.sqlpp
@@ -0,0 +1,107 @@
+/*
+ * 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  : This test case is to verify the fix for issue562
+ * https://code.google.com/p/asterixdb/issues/detail?id=562
+ * Expected Res : SUCCESS
+ * Date         : 15th Jan. 2015
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+declare function q22_customer_tmp() {
+(
+    select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':phone_substr}
+    from  Customer as c
+    with  phone_substr as tpch.substring(c.c_phone,1,2)
+    where ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17'))
+)
+};
+with  avg as tpch.avg((
+      select element c.c_acctbal
+      from  Customer as c
+      with  phone_substr as tpch.substring(c.c_phone,1,2)
+      where ((c.c_acctbal > 0.0) and ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17')))
+  ))
+select element {'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.sum((
+        select element i.c_acctbal
+        from  ct as i
+    ))}
+from  tpch.q22_customer_tmp() as ct
+where (tpch.count((
+    select element o
+    from  Orders as o
+    where (ct.c_custkey = o.o_custkey)
+)) = 0)
+group by ct.cntrycode as cntrycode
+order by cntrycode
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue601.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue601.sqlpp
new file mode 100644
index 0000000..5f60eb0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue601.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+select element {'l_linenumber':l_linenumber,'count_order':tpch.count(l)}
+from  LineItem as l
+group by l.l_linenumber as l_linenumber
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue697.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue697.sqlpp
new file mode 100644
index 0000000..5d23126
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue697.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue697
+ * https://code.google.com/p/asterixdb/issues/detail?id=697
+ * Expected Result : Success
+ * Date            : 16th Nov. 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  key1 : int32,
+  "value" : int32
+}
+
+create  table test(TestType) primary key key1;
+
+select element {'gid':aid,'avg':test.avg((
+        select element j."value"
+        from  i as j
+        where test.not(test."is-null"(j."value"))
+    ))}
+from  test as i
+group by i.key1 as aid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue785.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue785.sqlpp
new file mode 100644
index 0000000..aecafb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue785.sqlpp
@@ -0,0 +1,121 @@
+/*
+ * 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  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
+with  t as (
+      select element {'n_nationkey':nation.n_nationkey,'n_name':nation.n_name}
+      from  Nation as nation,
+            SelectedNation as sn
+      where (nation.n_nationkey = sn.n_nationkey)
+  ),
+      X as (
+      select element {'nation_key':nation_key,'order_date':orderdate,'sum_price':sum}
+      from  t as n,
+            Customer as customer,
+            Orders as orders
+      where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = n.n_nationkey))
+      group by orders.o_orderdate as orderdate,n.n_nationkey as nation_key
+      with  sum as tpch.sum((
+            select element o.o_totalprice
+            from  orders as o
+        ))
+  )
+select element {'nation_key':nation_key,'sum_price':(
+        select element {'orderdate':y.order_date,'sum_price':y.sum_price}
+        from  x as y
+        order by y.sum_price desc
+        limit 3
+    )}
+from  X as x
+group by x.nation_key as nation_key
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue810-2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue810-2.sqlpp
new file mode 100644
index 0000000..b2e4121
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue810-2.sqlpp
@@ -0,0 +1,78 @@
+/*
+ * 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  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 24th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'count_cheaps':tpch.count(cheaps),'avg_expensive_discounts':tpch.avg(expensives),'sum_disc_prices':tpch.sum(disc_prices),'total_charges':tpch.sum(charges)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+with  expensives as (
+      select element i.l_discount
+      from  l as i
+      where (i.l_discount <= 0.05)
+  ),
+      cheaps as (
+      select element i
+      from  l as i
+      where (i.l_discount > 0.05)
+  ),
+      charges as (
+      select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+      from  l as i
+  ),
+      disc_prices as (
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  )
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue810.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue810.sqlpp
new file mode 100644
index 0000000..da41e12
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue810.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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     : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Result : Success
+ * Date            : 16th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'count_cheaps':tpch.count(cheap),'count_expensives':tpch.count(expensive)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+with  cheap as (
+      select element m
+      from  l as m
+      where (m.l_discount > 0.05)
+  ),
+      expensive as (
+      select element a
+      from  l as a
+      where (a.l_discount <= 0.05)
+  )
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue827-2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue827-2.sqlpp
new file mode 100644
index 0000000..c5ad063
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query-issue827-2.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 3rd Dec. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+{'sum_qty_partial':tpch.sum((
+    select element i.l_quantity
+    from  LineItem as i
+    where (i.l_shipdate <= '1998-09-02')
+)),'sum_base_price':tpch.sum((
+    select element i.l_extendedprice
+    from  LineItem as i
+)),'sum_disc_price':tpch.sum((
+    select element (i.l_extendedprice * (1 - i.l_discount))
+    from  LineItem as i
+)),'sum_charge':tpch.sum((
+    select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+    from  LineItem as i
+)),'ave_qty':tpch.avg((
+    select element i.l_quantity
+    from  LineItem as i
+    where (i.l_shipdate <= '1998-09-02')
+)),'ave_price':tpch.avg((
+    select element i.l_extendedprice
+    from  LineItem as i
+)),'ave_disc':tpch.avg((
+    select element i.l_discount
+    from  LineItem as i
+)),'count_order':tpch.count((
+    select element l
+    from  LineItem as l
+))};
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query_issue849-2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query_issue849-2.sqlpp
new file mode 100644
index 0000000..1d0fda5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query_issue849-2.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.sType as
+ closed {
+  b : int32
+}
+
+create  table s(sType) primary key b;
+
+insert into s
+select element {'b':1};
+insert into s
+select element {'b':3};
+select element {'x':x,'y':y}
+from  s as x,
+      (
+    select element z.c
+    from  {{{'a':1,'c':1},{'a':2,'c':2},{'a':1,'c':null}}} as z
+    where (x.b = z.a)
+) as y
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query_issue849.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query_issue849.sqlpp
new file mode 100644
index 0000000..a843dad
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/query_issue849.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.sType as
+ closed {
+  b : int32
+}
+
+create  table s(sType) primary key b;
+
+insert into s
+select element {'b':1};
+insert into s
+select element {'b':3};
+select element {'x':x,'y':y}
+from  {{{'a':1},{'a':2}}} as x,
+      (
+    select element z.b
+    from  s as z
+    where (x.a = z.b)
+) as y
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-numeric-desc.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-numeric-desc.sqlpp
new file mode 100644
index 0000000..8cdc933
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-numeric-desc.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.
+ */
+/*
+ *  Description     : The hint is to use the range connector
+ *                  : This test is intended to verify that the range connector is used instead of single node merge.
+ *  Expected Result : Success
+ *  Date            : 1th May 2015
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+select element user
+from  TwitterUsers as user
+order by user.friends_count desc
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-numeric.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-numeric.sqlpp
new file mode 100644
index 0000000..682d26b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-numeric.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.
+ */
+/*
+ *  Description     : The hint is to use the range connector
+ *                  : This test is intended to verify that the range connector is used instead of single node merge.
+ *  Expected Result : Success
+ *  Date            : 1th May 2015
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+select element user
+from  TwitterUsers as user
+order by user.friends_count
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-string-desc.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-string-desc.sqlpp
new file mode 100644
index 0000000..cd1c196
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-string-desc.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.
+ */
+/*
+ *  Description     : The hint is to use the range connector
+ *                  : This test is intended to verify that the range connector is used instead of single node merge.
+ *  Expected Result : Success
+ *  Date            : 1th May 2015
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+select element user
+from  TwitterUsers as user
+order by user."screen-name" desc
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-string.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-string.sqlpp
new file mode 100644
index 0000000..a400bd3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/range-connector/sort-hint-on-closed-string.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.
+ */
+/*
+ *  Description     : The hint is to use the range connector
+ *                  : This test is intended to verify that the range connector is used instead of single node merge.
+ *  Expected Result : Success
+ *  Date            : 1th May 2015
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+select element user
+from  TwitterUsers as user
+order by user."screen-name"
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/record_access.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/record_access.sqlpp
new file mode 100644
index 0000000..84602a2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/record_access.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"/tmp/rec_access.adm"
+{'a':2}.a;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/issue730.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/issue730.sqlpp
new file mode 100644
index 0000000..a9a137d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/issue730.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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  : Test that left-outer-join may use an available rtree index in index subtree.
+ * Issue        : 730              
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+{
+  screen_name : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  sender_location : point?,
+  send_time : datetime,
+  referred_topics : {{string}},
+  message_text : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (sender_location) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_issue730.adm"
+select element {'message':t1.tweetid,'nearby-message':(
+        select element t2.tweetid
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.sender_location,n)
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.sender_location,5.0)
+where ((t1.send_time >= test.datetime('2011-06-18T14:10:17')) and (t1.send_time < test.datetime('2011-06-18T15:10:17')))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
new file mode 100644
index 0000000..f936fea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
new file mode 100644
index 0000000..160816f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32,
+  countB : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
+write output to nc1:"rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2."sender-location",n) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/query-issue838.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/query-issue838.sqlpp
new file mode 100644
index 0000000..3a2364d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/query-issue838.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : This test case is to verify the fix for issue838
+ * https://code.google.com/p/asterixdb/issues/detail?id=838
+ * Expected Res : SUCCESS
+ * Date         : 18 Dec. 2014
+ */
+
+drop  database twitter if exists;
+create  database twitter;
+
+use twitter;
+
+
+create type twitter.TweetMessageType as
+ closed {
+  tweetid : int64,
+  "sender-location" : point,
+  text : string
+}
+
+create type twitter.TweetHistorySubscription as
+{
+  "subscription-id" : int32,
+  location : point
+}
+
+create  table TweetHistorySubscriptions(TweetHistorySubscription) primary key "subscription-id";
+
+create  index testa  on TweetHistorySubscriptions (location) type rtree;
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index locationIdx  on TweetMessages ("sender-location") type rtree;
+
+write output to nc1:"rttest/query-issue838.adm"
+select element {'subscription-id':sub."subscription-id",'changeSet':1,'execution-time':twitter."current-datetime"(),'message-text':text}
+from  TweetHistorySubscriptions as sub,
+      (
+    select element tweet
+    from  TweetMessages as tweet
+    with  circle as twitter."create-circle"(location,30.0)
+    where twitter."spatial-intersect"(tweet."sender-location",circle)
+) as text
+with  location as sub.location
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_01.sqlpp
new file mode 100644
index 0000000..9319186
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_01.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData1(MyRecord) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (point) type rtree;
+
+write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_02.sqlpp
new file mode 100644
index 0000000..94d47b6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_02.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData2' has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData1(MyRecord) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData2 (point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_03.sqlpp
new file mode 100644
index 0000000..b57ad65
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-index-join/spatial-intersect-point_03.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.
+ */
+/*
+ * Description    : Self-joins a dataset on the intersection of its point attribute.
+ *                  The dataset has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  index rtree_index  on MyData (point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_03.adm"
+select element {'a':a,'b':b}
+from  MyData as a,
+      MyData as b
+where test."spatial-intersect"(a.point,b.point)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-secondary-index-open.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-secondary-index-open.sqlpp
new file mode 100644
index 0000000..c7b5d36
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-secondary-index-open.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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table MyData(MyRecord) primary key id on group1;
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
+write output to nc1:"rttest/index_rtree-secondary-index-open.adm"
+select element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-secondary-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-secondary-index.sqlpp
new file mode 100644
index 0000000..0fae89e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/rtree-secondary-index.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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table MyData(MyRecord) primary key id on group1;
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
+write output to nc1:"rttest/index_rtree-secondary-index.adm"
+select element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete-all.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete-all.sqlpp
new file mode 100644
index 0000000..1a277ce
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete-all.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.LineIDType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems_q1(LineItemType) primary key l_orderkey on group1;
+
+create  table LineID(LineIDType) primary key l_orderkey on group1;
+
+delete l from LineItems_q1
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete-rtree-secondary-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete-rtree-secondary-index.sqlpp
new file mode 100644
index 0000000..6266272
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete-rtree-secondary-index.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table MyData(MyRecord) primary key id on group1;
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
+delete m from MyData
+ where (m.id > 5);
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete.sqlpp
new file mode 100644
index 0000000..0185c84
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-delete.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.LineIDType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems_q1(LineItemType) primary key l_orderkey on group1;
+
+create  table LineID(LineIDType) primary key l_orderkey on group1;
+
+delete l from LineItems_q1
+ where (l.l_shipdate <= '1998-09-02');
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-insert-secondary-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-insert-secondary-index.sqlpp
new file mode 100644
index 0000000..020baf7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-insert-secondary-index.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.LineIDType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems_q1(LineItemType) primary key l_orderkey on group1;
+
+create  table LineID(LineIDType) primary key l_orderkey on group1;
+
+create  index idx_LineID_partkey  on LineID (l_partkey) type btree;
+
+create  index idx_LineID_suppkey  on LineID (l_suppkey) type btree;
+
+insert into LineID
+select element {'l_orderkey':l.l_orderkey,'l_partkey':l.l_partkey,'l_suppkey':l.l_partkey}
+from  LineItems_q1 as l
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-insert.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-insert.sqlpp
new file mode 100644
index 0000000..2de1b31
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/scan-insert.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.LineIDType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems_q1(LineItemType) primary key l_orderkey on group1;
+
+create  table LineID(LineIDType) primary key l_orderkey on group1;
+
+insert into LineID
+select element {'l_orderkey':l.l_orderkey,'l_partkey':l.l_partkey,'l_suppkey':l.l_partkey}
+from  LineItems_q1 as l
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..3e7ef15
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_01.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a "<=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_01.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (ed <= 2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_02.sqlpp
new file mode 100644
index 0000000..98506e9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_02.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause. 
+ *                  Replacement should happen because of a reverse "<=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_02.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (2 >= ed)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_03.sqlpp
new file mode 100644
index 0000000..c5a255a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a "<" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_03.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (ed < 3)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_04.sqlpp
new file mode 100644
index 0000000..3ad6b13
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_04.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a reverse "<" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_04.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (3 > ed)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_05.sqlpp
new file mode 100644
index 0000000..ba5ed31
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_05.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a ">=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_05.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (ed >= 2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_06.sqlpp
new file mode 100644
index 0000000..2bc08b3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_06.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                   Replacement should *not* happen because of a reverse ">=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_06.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (2 <= ed)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_07.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_07.sqlpp
new file mode 100644
index 0000000..7aac82d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_07.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a ">" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_07.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (ed > 2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_08.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_08.sqlpp
new file mode 100644
index 0000000..2758920
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-let-to-edit-distance-check_08.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a reverse ">" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-let-to-edit-distance-check_08.adm"
+select element ed
+from  DBLP as o
+with  ed as test."edit-distance"(o.authors,'Michael J. Carey')
+where (2 < ed)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_01.sqlpp
new file mode 100644
index 0000000..12eb414
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_01.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should happen because of a "<=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_01.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Michael J. Carey') <= 2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_02.sqlpp
new file mode 100644
index 0000000..41893bb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_02.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should happen because of a reverse "<=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_02.adm"
+select element o
+from  DBLP as o
+where (2 >= test."edit-distance"(o.authors,'Michael J. Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_03.sqlpp
new file mode 100644
index 0000000..10a0ef3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_03.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should happen because of a "<" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_03.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Michael J. Carey') < 3)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_04.sqlpp
new file mode 100644
index 0000000..d9230b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_04.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should happen because of a reverse "<" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_04.adm"
+select element o
+from  DBLP as o
+where (3 > test."edit-distance"(o.authors,'Michael J. Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_05.sqlpp
new file mode 100644
index 0000000..90b3655
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_05.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should *not* happen because of a ">=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_05.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Michael J. Carey') >= 2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_06.sqlpp
new file mode 100644
index 0000000..2340250
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_06.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should *not* happen because of a reverse ">=" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_06.adm"
+select element o
+from  DBLP as o
+where (2 <= test."edit-distance"(o.authors,'Michael J. Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_07.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_07.sqlpp
new file mode 100644
index 0000000..8b9f5c6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_07.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should *not* happen because of a ">" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_07.adm"
+select element o
+from  DBLP as o
+where (test."edit-distance"(o.authors,'Michael J. Carey') > 2)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_08.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_08.sqlpp
new file mode 100644
index 0000000..713c2b7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/edit-distance-to-edit-distance-check_08.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the edit-distance function with a threshold 
+ *                  into edit-distance-check if possible.
+ *                  Replacement should *not* happen because of a reverse ">" condition on the edit distance.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_edit-distance-to-edit-distance-check_08.adm"
+select element o
+from  DBLP as o
+where (2 < test."edit-distance"(o.authors,'Michael J. Carey'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/fuzzyeq-to-edit-distance-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/fuzzyeq-to-edit-distance-check.sqlpp
new file mode 100644
index 0000000..6d350d2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/fuzzyeq-to-edit-distance-check.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests that the FuzzyEqRule rewrites ~= using edit distance 
+ *                  into edit-distance-check.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_fuzzyeq-to-edit-distance-check.adm"
+set "simfunction" "edit-distance";
+
+set "simthreshold" "1";
+
+select element o
+from  DBLP as o
+where (o.authors ~= 'Michael J. Carey')
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/fuzzyeq-to-jaccard-check.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/fuzzyeq-to-jaccard-check.sqlpp
new file mode 100644
index 0000000..266c2fd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/fuzzyeq-to-jaccard-check.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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    : Tests that the FuzzyEqRule rewrites ~= using Jaccard 
+ *                  into edit-distance-check.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_fuzzyeq-to-jaccard-check.adm"
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.8f";
+
+select element paper
+from  DBLP as paper
+where (test."word-tokens"(paper.title) ~= test."word-tokens"('Transactions for Cooperative Environments'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..3ea9c76
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_01.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a ">=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (jacc >= 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..380d68d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_02.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a reverse ">=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (0.800000f <= jacc)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..93827db
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_03.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a ">" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (jacc > 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..0c63957
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_04.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should happen because of a reverse ">" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (0.800000f < jacc)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_05.sqlpp
new file mode 100644
index 0000000..8cec9c9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_05.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a "<=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (jacc <= 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_06.sqlpp
new file mode 100644
index 0000000..85f9d4a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_06.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a reverse "<=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (0.800000f >= jacc)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_07.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_07.sqlpp
new file mode 100644
index 0000000..c95130d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_07.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a "<" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (jacc < 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_08.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_08.sqlpp
new file mode 100644
index 0000000..67d1f31
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-let-to-jaccard-check_08.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Tests that the optimizer drills through the let clause.
+ *                  Replacement should *not* happen because of a reverse "<" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-let-to-jaccard-check_01.adm"
+select element jacc
+from  DBLP as paper
+with  jacc as test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (0.800000f > jacc)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_01.sqlpp
new file mode 100644
index 0000000..65e63ba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_01.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should happen because of a ">=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_01.adm"
+select element paper
+from  DBLP as paper
+where (test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')) >= 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_02.sqlpp
new file mode 100644
index 0000000..f40628fe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_02.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should happen because of a reverse ">=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_02.adm"
+select element paper
+from  DBLP as paper
+where (0.800000f <= test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_03.sqlpp
new file mode 100644
index 0000000..c9f9bcf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_03.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should happen because of a ">" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_02.adm"
+select element paper
+from  DBLP as paper
+where (test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')) > 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_04.sqlpp
new file mode 100644
index 0000000..e5e283b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_04.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should happen because of a reverse ">" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_03.adm"
+select element paper
+from  DBLP as paper
+where (0.800000f < test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_05.sqlpp
new file mode 100644
index 0000000..36d67d8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_05.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should *not* happen because of a "<=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_05.adm"
+select element paper
+from  DBLP as paper
+where (test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')) <= 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_06.sqlpp
new file mode 100644
index 0000000..19418f0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_06.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should *not* happen because of a reverse "<=" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_06.adm"
+select element paper
+from  DBLP as paper
+where (0.800000f >= test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_07.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_07.sqlpp
new file mode 100644
index 0000000..0be0017
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_07.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should *not* happen because of a "<" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_07.adm"
+select element paper
+from  DBLP as paper
+where (test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')) < 0.800000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_08.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_08.sqlpp
new file mode 100644
index 0000000..63eb76d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/similarity/jaccard-to-jaccard-check_08.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.
+ */
+/*
+ * Description    : Tests that the SimilarityCheckRule rewrites the similarity-jaccard function with a threshold 
+ *                  into similarity-jaccard-check-check if possible.
+ *                  Replacement should *not* happen because of a reverse "<" condition on the similarity.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+write output to nc1:"rttest/similarity_jaccard-to-jaccard-check_08.adm"
+select element paper
+from  DBLP as paper
+where (0.800000f > test."similarity-jaccard"(test."word-tokens"(paper.title),test."word-tokens"('Transactions for Cooperative Environments')))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/dont-skip-primary-index-search-in-delete.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/dont-skip-primary-index-search-in-delete.sqlpp
new file mode 100644
index 0000000..b7f8751
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/dont-skip-primary-index-search-in-delete.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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     : The hint to skip secondary indexes don't apply to the primary index
+ *                  : This test is intended to verify that the primary index is still used instead of a scan
+ *  Expected Result : Success
+ *  Date            : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+delete c from Customers
+ where (c.cid /*+ skip-index */  < 10);
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/dont-skip-primary-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/dont-skip-primary-index.sqlpp
new file mode 100644
index 0000000..5917ad8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/dont-skip-primary-index.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : The hint to skip secondary indexes don't apply to the primary index
+ *                  : This test is intended to verify that the primary index is still used instead of a scan 
+ *  Expected Result : Success
+ *  Date            : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-16.adm"
+create type test.TestType as
+{
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key fname,lname;
+
+select element emp
+from  testdst as emp
+where ((emp.fname /*+ skip-index */  >= 'Craig') and (emp.lname /*+ skip-index */  >= 'Kevin') and (emp.fname /*+ skip-index */  <= 'Mary') and (emp.lname /*+ skip-index */  <= 'Tomes'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-ngram-index-search-in-delete.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-ngram-index-search-in-delete.sqlpp
new file mode 100644
index 0000000..9111891
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-ngram-index-search-in-delete.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+delete o from DBLP
+ where  /*+ skip-index */ test.contains(o.title,'Multimedia');
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-ngram-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-ngram-index.sqlpp
new file mode 100644
index 0000000..a79796d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-ngram-index.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm"
+select element o
+from  DBLP as o
+where  /*+ skip-index */ test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-rtree-index-search-in-delete.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-rtree-index-search-in-delete.sqlpp
new file mode 100644
index 0000000..a91f5b8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-rtree-index-search-in-delete.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
+delete m from MyData
+ where  /*+ skip-index */ test."spatial-intersect"(m.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]));
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-rtree-secondary-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-rtree-secondary-index.sqlpp
new file mode 100644
index 0000000..da48031
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-rtree-secondary-index.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table MyData(MyRecord) primary key id on group1;
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
+write output to nc1:"rttest/index_rtree-secondary-index.adm"
+select element {'id':o.id}
+from  MyData as o
+where  /*+ skip-index */ test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index-2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index-2.sqlpp
new file mode 100644
index 0000000..0c0170b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index-2.sqlpp
@@ -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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname /*+ skip-index */  >= 'Max') and (emp.fname <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index-search-in-delete.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index-search-in-delete.sqlpp
new file mode 100644
index 0000000..b54fc9c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index-search-in-delete.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.
+ */
+/*
+ * Description  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  index age_index  on Customers (age) type btree;
+
+delete c from Customers
+ where (c.age /*+ skip-index */  < 20);
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index.sqlpp
new file mode 100644
index 0000000..c7c6505
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-secondary-btree-index.sqlpp
@@ -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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm"
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname) type btree;
+
+select element emp
+from  testdst as emp
+where ((emp.fname /*+ skip-index */  >= 'Max') and (emp.fname /*+ skip-index */  <= 'Roger'))
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-word-index-search-in-delete.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-word-index-search-in-delete.sqlpp
new file mode 100644
index 0000000..36a9716
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-word-index-search-in-delete.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+delete o from DBLP
+ where ( /*+ skip-index */ test."similarity-jaccard"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments')) >= 0.500000f);
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-word-index.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-word-index.sqlpp
new file mode 100644
index 0000000..8b957ed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/skip-index/skip-word-index.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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  : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date         : 21th December 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm"
+select element o
+from  DBLP as o
+with  jacc as  /*+ skip-index */ test."similarity-jaccard"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'))
+where (jacc >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/sort-cust.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/sort-cust.sqlpp
new file mode 100644
index 0000000..cad7ac5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/sort-cust.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.
+ */
+
+drop  database custlimit if exists;
+create  database custlimit;
+
+use custlimit;
+
+
+create type custlimit.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type custlimit.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
+write output to nc1:"/tmp/custlimit.adm"
+select element {'custname':c.name,'custage':c.age}
+from  Customers as c
+order by c.age
+limit 10
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/split-materialization-above-join.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/split-materialization-above-join.sqlpp
new file mode 100644
index 0000000..07ccedc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/split-materialization-above-join.sqlpp
@@ -0,0 +1,82 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+set "import-private-functions" "true";
+
+select element {'left':paperLeft,'right':paperRight,'sim':ridpair.sim}
+from  DBLP as paperLeft,
+      DBLP as paperRight,
+      (
+    select element {'idLeft':idLeft,'idRight':idRight,'sim':sim[0]}
+    from  DBLP as paperLeft,
+          fuzzyjoin."subset-collection"(tokensLeft,0,fuzzyjoin."prefix-len-jaccard"(lenLeft,0.500000f)) as prefixTokenLeft,
+          DBLP as paperRight,
+          fuzzyjoin."subset-collection"(tokensRight,0,fuzzyjoin."prefix-len-jaccard"(lenRight,0.500000f)) as prefixTokenRight
+    with  lenLeft as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperLeft.title)),
+          tokensLeft as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperLeft.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          lenRight as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperRight.title)),
+          tokensRight as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperRight.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenLeft,tokensLeft,lenRight,tokensRight,prefixTokenLeft,0.500000f)
+    where ((prefixTokenLeft = prefixTokenRight) and ((sim >= 0.500000f) and (paperLeft.id < paperRight.id)))
+    group by paperLeft.id as idLeft,paperRight.id as idRight
+) as ridpair
+where ((ridpair.idLeft = paperLeft.id) and (ridpair.idRight = paperRight.id))
+order by paperLeft.id,paperRight.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/split-materialization.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/split-materialization.sqlpp
new file mode 100644
index 0000000..9f9d609
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/split-materialization.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int32}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+with  lonelyusers as (
+      select element d
+      from  FacebookUsers as d
+      where (TinySocial.count(d."friend-ids") < 2)
+  ),
+      lonelyusers2 as (
+      select element d
+      from  FacebookUsers as d
+      where (TinySocial.count(d."friend-ids") < 2)
+  )
+select element {'user1':{'id':l1.id,'name':l1.name},'user2':{'id':l2.id,'name':l2.name}}
+from  lonelyusers as l1,
+      lonelyusers2 as l2
+where (l1.id < l2.id)
+order by l1.id,l2.id
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest-to-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest-to-join_01.sqlpp
new file mode 100644
index 0000000..8f3b759
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest-to-join_01.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests that non-datascan unnests are rewritten into joins.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/unnest-to-join_01.adm"
+select element y
+from  [1,2,3,4,5,6] as x,
+      [4,5,6,7,8,9] as y
+where (x = y)
+;
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest-to-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest-to-join_02.sqlpp
new file mode 100644
index 0000000..5b025be
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest-to-join_02.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.
+ */
+/*
+ * Description    : Tests that non-datascan unnests in a subplan are rewritten into joins.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/unnest-to-join_02.adm"
+select element some x in [1,2,3,4,5,6],
+y in [4,5,6,7,8,9] satisfies (x = y);
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest_list_in_subplan.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest_list_in_subplan.sqlpp
new file mode 100644
index 0000000..fa22c8f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/unnest_list_in_subplan.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.TOKENSRANKEDADMType as
+ closed {
+  token : int32,
+  rank : int32
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table TOKENSRANKEDADM(TOKENSRANKEDADMType) primary key rank on group1;
+
+write output to nc1:"rttest/unnest_list_in_subplan.adm"
+select element {'id':idDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      tokensDBLP as (
+      select element tokenRanked.rank
+      from  tokensUnrankedDBLP as tokenUnranked,
+            TOKENSRANKEDADM as tokenRanked
+      where (tokenUnranked = tokenRanked.token)
+      order by tokenRanked.rank
+  )
+;
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.ast
new file mode 100644
index 0000000..d6c8138
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.ast
@@ -0,0 +1,122 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.ast
new file mode 100644
index 0000000..5026149
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.ast
@@ -0,0 +1,136 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_01.ast
new file mode 100644
index 0000000..8c2366b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_01.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_02.ast
new file mode 100644
index 0000000..b1c3124
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_02.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_03.ast
new file mode 100644
index 0000000..eedb46d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-join_03.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_01.ast
new file mode 100644
index 0000000..be04f55
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_01.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_02.ast
new file mode 100644
index 0000000..b648a3d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_02.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_03.ast
new file mode 100644
index 0000000..09c0cf9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_03.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_04.ast
new file mode 100644
index 0000000..fe0e3ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_04.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_05.ast
new file mode 100644
index 0000000..5b1bc19
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_05.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_06.ast
new file mode 100644
index 0000000..55abe5a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-composite-key-prefix-join_06.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl Names(Name) partitioned by [[fname], [lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_06.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-multipred.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-multipred.ast
new file mode 100644
index 0000000..95df3cf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-multipred.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join-multipred.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer]
+    :
+    Variable [ Name=c ]
+  )
+  (
+    LiteralExpr [STRING] [order]
+    :
+    Variable [ Name=o ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=cid
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=name
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=orderstatus
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=age
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-neg_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-neg_01.ast
new file mode 100644
index 0000000..3043316
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-neg_01.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join-neg_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key1
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-neg_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-neg_02.ast
new file mode 100644
index 0000000..85ef8e3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join-neg_02.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join-neg_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key2
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_01.ast
new file mode 100644
index 0000000..b44716f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_01.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key1
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_02.ast
new file mode 100644
index 0000000..97549ca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_02.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key2
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_03.ast
new file mode 100644
index 0000000..b82bf03
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_03.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer]
+    :
+    Variable [ Name=c ]
+  )
+  (
+    LiteralExpr [STRING] [order]
+    :
+    Variable [ Name=o ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_04.ast
new file mode 100644
index 0000000..99e226d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_04.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer]
+    :
+    Variable [ Name=c ]
+  )
+  (
+    LiteralExpr [STRING] [order]
+    :
+    Variable [ Name=o ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_05.ast
new file mode 100644
index 0000000..92e52c27
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-equi-join_05.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_06.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer1]
+    :
+    Variable [ Name=c1 ]
+  )
+  (
+    LiteralExpr [STRING] [customer2]
+    :
+    Variable [ Name=c2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c2 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c1 ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=c2 ]
+      Field=cid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-ge-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-ge-join_01.ast
new file mode 100644
index 0000000..a266c98
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-ge-join_01.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-ge-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key1
+    ]
+    >=
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-ge-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-ge-join_02.ast
new file mode 100644
index 0000000..a09412a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-ge-join_02.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-ge-join_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key2
+    ]
+    <=
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-gt-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-gt-join_01.ast
new file mode 100644
index 0000000..e9e3044
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-gt-join_01.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-gt-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key1
+    ]
+    >
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-gt-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-gt-join_02.ast
new file mode 100644
index 0000000..ab0f98d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-gt-join_02.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-gt-join_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key2
+    ]
+    <
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-le-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-le-join_01.ast
new file mode 100644
index 0000000..1db7da8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-le-join_01.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-le-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key1
+    ]
+    <=
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-le-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-le-join_02.ast
new file mode 100644
index 0000000..a185ca0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-le-join_02.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-le-join_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key2
+    ]
+    >=
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-lt-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-lt-join_01.ast
new file mode 100644
index 0000000..4b6d4e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-lt-join_01.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-lt-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key1
+    ]
+    <
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-lt-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-lt-join_02.ast
new file mode 100644
index 0000000..58c261f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/primary-lt-join_02.ast
@@ -0,0 +1,39 @@
+TypeDecl TestType [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-lt-join_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=key2
+    ]
+    >
+    FieldAccessor [
+      Variable [ Name=y ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join-multiindex.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join-multiindex.ast
new file mode 100644
index 0000000..0b8f887
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join-multiindex.ast
@@ -0,0 +1,117 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  closed RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int32,
+    id-copy : int32,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    user-since-copy : datetime,
+    friend-ids : UnorderedList <int32>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int32,
+    message-id-copy : int32,
+    author-id : int32,
+    author-id-copy : int32,
+    in-response-to : int32?,
+    sender-location : point?,
+    message : string
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multiindex.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [fbu-ID]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fbm-auth-ID]
+    :
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=author-id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=message
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=message ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=author-id-copy
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      >=
+      LiteralExpr [LONG] [11000]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      <=
+      LiteralExpr [LONG] [12000]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join-multipred.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join-multipred.ast
new file mode 100644
index 0000000..76e06aa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join-multipred.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multipred.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=misc
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=misc
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_01.ast
new file mode 100644
index 0000000..61b4973
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_01.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_02.ast
new file mode 100644
index 0000000..6193ed6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_02.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_03.ast
new file mode 100644
index 0000000..060dec8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index-join/secondary-equi-join_03.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-01.ast
new file mode 100644
index 0000000..129cf33
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-01.ast
@@ -0,0 +1,50 @@
+DataverseUse emergencyTest
+TypeDecl CHPReport [
+  open RecordType {
+    id : int64,
+    timestamp : datetime,
+    title : string,
+    message : string
+  }
+]
+DatasetDecl CHPReports(CHPReport) partitioned by [[timestamp]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emergency ]
+  Field=message
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CHPReports]
+  ]
+  AS
+  Variable [ Name=emergency ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emergency ]
+        Field=timestamp
+      ]
+      >=
+      OperatorExpr [
+        FunctionCall emergencyTest.current-datetime@0[
+        ]
+        -
+        FunctionCall emergencyTest.day-time-duration@1[
+          LiteralExpr [STRING] [PT10H]
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emergency ]
+        Field=title
+      ]
+      =
+      LiteralExpr [STRING] [ghost]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-02.ast
new file mode 100644
index 0000000..3197add
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-02.ast
@@ -0,0 +1,39 @@
+DataverseUse emergencyTest
+TypeDecl CHPReport [
+  open RecordType {
+    id : int64,
+    timestamp : datetime,
+    title : string,
+    message : string
+  }
+]
+DatasetDecl CHPReports(CHPReport) partitioned by [[timestamp]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emergency ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CHPReports]
+  ]
+  AS
+  Variable [ Name=emergency ]
+]
+LetVariable [ Name=time ]
+  :=
+  OperatorExpr [
+    FunctionCall emergencyTest.current-datetime@0[
+    ]
+    -
+    FunctionCall emergencyTest.day-time-duration@1[
+      LiteralExpr [STRING] [PT10H]
+    ]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emergency ]
+      Field=timestamp
+    ]
+    >=
+    Variable [ Name=time ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-03.ast
new file mode 100644
index 0000000..7b7241a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-03.ast
@@ -0,0 +1,30 @@
+DataverseUse emergencyTest
+TypeDecl CHPReport [
+  open RecordType {
+    id : int64,
+    timestamp : datetime,
+    title : string,
+    message : string
+  }
+]
+DatasetDecl CHPReports(CHPReport) partitioned by [[timestamp]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emergency ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CHPReports]
+  ]
+  AS
+  Variable [ Name=emergency ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emergency ]
+      Field=timestamp
+    ]
+    >=
+    FunctionCall emergencyTest.current-datetime@0[
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-04.ast
new file mode 100644
index 0000000..4abc056
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-datetime-04.ast
@@ -0,0 +1,30 @@
+DataverseUse emergencyTest
+TypeDecl CHPReport [
+  open RecordType {
+    id : int64,
+    timestamp : datetime,
+    title : string,
+    message : string
+  }
+]
+DatasetDecl CHPReports(CHPReport) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emergency ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CHPReports]
+  ]
+  AS
+  Variable [ Name=emergency ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emergency ]
+      Field=timestamp
+    ]
+    >=
+    FunctionCall emergencyTest.current-datetime@0[
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-01.ast
new file mode 100644
index 0000000..21fa932
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-01.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-01.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-02.ast
new file mode 100644
index 0000000..ca7d005
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-02.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-02.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Susan]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-03.ast
new file mode 100644
index 0000000..64b2ed0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-03.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-03.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Isa]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-04.ast
new file mode 100644
index 0000000..8994a2b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-04.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-04.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Vanpatten]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-05.ast
new file mode 100644
index 0000000..47d7a34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-05.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-05.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    !=
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-06.ast
new file mode 100644
index 0000000..81b7977
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-06.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-06.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-07.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-07.ast
new file mode 100644
index 0000000..3b77aec
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-07.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-07.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=lname
+    ]
+    =
+    LiteralExpr [STRING] [Kim]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-08.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-08.ast
new file mode 100644
index 0000000..4422ab2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-08.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-08.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Young Seok]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Kim]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-09.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-09.ast
new file mode 100644
index 0000000..42348bf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-09.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-09.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Malaika]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-10.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-10.ast
new file mode 100644
index 0000000..6633379
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-10.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-10.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Alex]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zach]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-11.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-11.ast
new file mode 100644
index 0000000..e1eee3f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-11.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-11.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zubi]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-12.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-12.ast
new file mode 100644
index 0000000..dc69e6a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-12.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-12.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-13.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-13.ast
new file mode 100644
index 0000000..4be9a71
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-13.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-13.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-14.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-14.ast
new file mode 100644
index 0000000..5db0d34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-14.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-14.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-15.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-15.ast
new file mode 100644
index 0000000..ff4ac5a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-15.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-15.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-16.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-16.ast
new file mode 100644
index 0000000..256f105
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-16.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-16.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-17.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-17.ast
new file mode 100644
index 0000000..f91833e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-17.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-17.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-18.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-18.ast
new file mode 100644
index 0000000..5bf9d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-18.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-18.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      !=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      !=
+      LiteralExpr [STRING] [Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-19.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-19.ast
new file mode 100644
index 0000000..811a232
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-19.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-19.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-20.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-20.ast
new file mode 100644
index 0000000..90be7db
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-20.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-20.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-21.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-21.ast
new file mode 100644
index 0000000..abe26d6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-21.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-21.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-22.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-22.ast
new file mode 100644
index 0000000..97b8952
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-22.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-22.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Sofia]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-23.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-23.ast
new file mode 100644
index 0000000..7b62e30
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-23.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-23.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Chen]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-24.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-24.ast
new file mode 100644
index 0000000..51ec059
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-24.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-24.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-25.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-25.ast
new file mode 100644
index 0000000..46f4398
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-25.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-25.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Neil]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-26.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-26.ast
new file mode 100644
index 0000000..05d74fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-26.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-26.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-27.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-27.ast
new file mode 100644
index 0000000..b175895
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-27.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-27.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-28.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-28.ast
new file mode 100644
index 0000000..15c06d0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-28.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-28.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-29.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-29.ast
new file mode 100644
index 0000000..687536e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-29.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-29.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-30.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-30.ast
new file mode 100644
index 0000000..e572543
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-30.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-30.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-31.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-31.ast
new file mode 100644
index 0000000..c5771bd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-31.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-31.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-32.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-32.ast
new file mode 100644
index 0000000..f2bf632
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-primary-32.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-32.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-33.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-33.ast
new file mode 100644
index 0000000..c75bd69
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-33.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-33.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-34.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-34.ast
new file mode 100644
index 0000000..b30daaa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-34.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-34.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Susan]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-35.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-35.ast
new file mode 100644
index 0000000..07ebdf7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-35.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-35.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Isa]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-36.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-36.ast
new file mode 100644
index 0000000..ec5a443
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-36.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-36.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Vanpatten]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-37.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-37.ast
new file mode 100644
index 0000000..6065247
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-37.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-37.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    !=
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-38.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-38.ast
new file mode 100644
index 0000000..1a0fdff
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-38.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-38.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-39.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-39.ast
new file mode 100644
index 0000000..bfd613a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-39.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-39.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=lname
+    ]
+    =
+    LiteralExpr [STRING] [Kim]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-40.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-40.ast
new file mode 100644
index 0000000..aa9bf67
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-40.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-40.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Young Seok]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Kim]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-41.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-41.ast
new file mode 100644
index 0000000..603c195
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-41.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-41.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Malaika]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-42.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-42.ast
new file mode 100644
index 0000000..6254e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-42.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-42.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Alex]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zach]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-43.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-43.ast
new file mode 100644
index 0000000..45b3d8c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-43.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-43.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zubi]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-44.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-44.ast
new file mode 100644
index 0000000..9b88340
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-44.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-44.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-45.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-45.ast
new file mode 100644
index 0000000..77d5eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-45.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-45.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-46.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-46.ast
new file mode 100644
index 0000000..75cdaab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-46.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-46.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-47.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-47.ast
new file mode 100644
index 0000000..9bace09
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-47.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-47.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-48.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-48.ast
new file mode 100644
index 0000000..58e8c0d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-48.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-48.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-49.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-49.ast
new file mode 100644
index 0000000..42aa6f3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-49.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-49.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-50.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-50.ast
new file mode 100644
index 0000000..96b2c09
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-50.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-50.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      !=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      !=
+      LiteralExpr [STRING] [Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-51.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-51.ast
new file mode 100644
index 0000000..ee61d0b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-51.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-51.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-52.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-52.ast
new file mode 100644
index 0000000..61475c9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-52.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-52.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-53.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-53.ast
new file mode 100644
index 0000000..05278a5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-53.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-53.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-54.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-54.ast
new file mode 100644
index 0000000..5fbf88d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-54.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-54.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-55.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-55.ast
new file mode 100644
index 0000000..bd2ddb1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-55.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-55.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Sofia]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-56.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-56.ast
new file mode 100644
index 0000000..a36f447
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-56.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-56.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Chen]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-57.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-57.ast
new file mode 100644
index 0000000..3c6bd5c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-57.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-57.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-58.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-58.ast
new file mode 100644
index 0000000..5765a06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-58.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-58.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Neil]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-59.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-59.ast
new file mode 100644
index 0000000..7f64667
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-59.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-59.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-60.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-60.ast
new file mode 100644
index 0000000..fd76fa1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-60.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-60.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-61.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-61.ast
new file mode 100644
index 0000000..21bce85
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-61.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-61.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-62.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-62.ast
new file mode 100644
index 0000000..1536c49
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-62.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-62.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-63.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-63.ast
new file mode 100644
index 0000000..ad1b845
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/btree-index/btree-secondary-63.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-63.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/collocated.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/collocated.ast
new file mode 100644
index 0000000..fd9a57d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/collocated.ast
@@ -0,0 +1,65 @@
+DataverseUse colocated
+TypeDecl UserType [
+  open RecordType {
+    uid : int32,
+    name : string,
+    lottery_numbers : UnorderedList <int32>
+
+  }
+]
+TypeDecl VisitorType [
+  open RecordType {
+    vid : int32,
+    name : string,
+    lottery_numbers : UnorderedList <int32>
+
+  }
+]
+DatasetDecl Users(UserType) partitioned by [[uid]]
+DatasetDecl Visitors(VisitorType) partitioned by [[vid]]
+WriteOutputTo nc1:/tmp/fuzzy1.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user_name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [visitor_name]
+    :
+    FieldAccessor [
+      Variable [ Name=visitor ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Users]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Visitors]
+  ]
+  AS
+  Variable [ Name=visitor ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=uid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=visitor ]
+      Field=vid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/consolidate-selects-complex.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/consolidate-selects-complex.ast
new file mode 100644
index 0000000..787d03f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/consolidate-selects-complex.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/consolidate-complex-selects.aql
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+  ]
+LetVariable [ Name=jacca ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+LetVariable [ Name=jaccb ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+LetVariable [ Name=jaccc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacca ]
+      Index:       Variable [ Name=jacca ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=jaccb ]
+      Index:       Variable [ Name=jaccb ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=authors
+      ]
+      =
+      LiteralExpr [STRING] [testauth]
+    ]
+    and
+    Variable [ Name=jaccc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/consolidate-selects-simple.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/consolidate-selects-simple.ast
new file mode 100644
index 0000000..da1791a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/consolidate-selects-simple.ast
@@ -0,0 +1,63 @@
+DataverseUse test
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+WriteOutputTo nc1:rttest/consolidate-selects-simple.aql
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_name
+      ]
+      =
+      LiteralExpr [STRING] [testname]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_address
+      ]
+      =
+      LiteralExpr [STRING] [testaddr]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_nationkey
+      ]
+      =
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_phone
+      ]
+      =
+      LiteralExpr [STRING] [123456789]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/const-folding.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/const-folding.ast
new file mode 100644
index 0000000..7b38d56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/const-folding.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/divide.adm
+Query:
+FieldAccessor [
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [a]
+      :
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        +
+        LiteralExpr [LONG] [2]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [b]
+      :
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [STRING] [foo]
+          LiteralExpr [STRING] [bar]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [STRING] [foo]
+          LiteralExpr [STRING] [bar]
+        ]
+      ]
+    )
+  ]
+  Field=b
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/count-tweets.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/count-tweets.ast
new file mode 100644
index 0000000..202abef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/count-tweets.ast
@@ -0,0 +1,58 @@
+DataverseUse twitter
+TypeDecl Tweet [
+  open RecordType {
+    id : int32,
+    tweetid : int64,
+    loc : point,
+    time : datetime,
+    text : string
+  }
+]
+DatasetDecl TwitterData(Tweet)is an external dataset
+WriteOutputTo nc1:/tmp/count-tweets.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [word]
+    :
+    Variable [ Name=tok ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall twitter.count@1[
+      Variable [ Name=token ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterData]
+  ]
+  AS
+  Variable [ Name=t ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tokens]
+  ]
+  AS
+  Variable [ Name=token ]
+]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall twitter.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=text
+    ]
+  ]
+Groupby
+  Variable [ Name=tok ]
+  :=
+  Variable [ Name=token ]
+  With
+  Variable [ Name=tokens ]
+  Variable [ Name=t ]
+  Variable [ Name=token ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/cust_group_no_agg.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/cust_group_no_agg.ast
new file mode 100644
index 0000000..c64af19
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/cust_group_no_agg.ast
@@ -0,0 +1,35 @@
+DataverseUse group_no_agg
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+WriteOutputTo nc1:/tmp/.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=name ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Groupby
+  Variable [ Name=name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_name
+  ]
+  With
+  Variable [ Name=c ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/denorm-cust-order.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/denorm-cust-order.ast
new file mode 100644
index 0000000..cf92da8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/denorm-cust-order.ast
@@ -0,0 +1,98 @@
+DataverseUse custorder
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
+WriteOutputTo nc1:/tmp/custorder.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cid]
+    :
+    Variable [ Name=cid ]
+  )
+  (
+    LiteralExpr [STRING] [cust]
+    :
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [cust]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cnt-orders]
+    :
+    FunctionCall custorder.count@1[
+      Variable [ Name=o ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orders]
+    :
+    Variable [ Name=o ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Groupby
+  Variable [ Name=cid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=o ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-1.ast
new file mode 100644
index 0000000..72cf10d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    idx : string,
+    no-idx : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-2.ast
new file mode 100644
index 0000000..72cf10d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-2.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    idx : string,
+    no-idx : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-3.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-3.ast
new file mode 100644
index 0000000..72cf10d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/disjunction-to-join-delete-3.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    idx : string,
+    no-idx : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/distinct_aggregate.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/distinct_aggregate.ast
new file mode 100644
index 0000000..44d9754
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/distinct_aggregate.ast
@@ -0,0 +1,128 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItems_q1(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+WriteOutputTo nc1:rttest/tpch_q1_pricing_summary_report_nt.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [count_suppkey]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=g ]
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_returnflag]
+        :
+        Variable [ Name=l_returnflag ]
+      )
+      (
+        LiteralExpr [STRING] [l_linestatus]
+        :
+        Variable [ Name=l_linestatus ]
+      )
+      (
+        LiteralExpr [STRING] [l_suppkey]
+        :
+        Variable [ Name=l_suppkey ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItems_q1]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipdate
+        ]
+        <=
+        LiteralExpr [STRING] [1998-09-02]
+      ]
+    Groupby
+      Variable [ Name=l_returnflag ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_returnflag
+      ]
+      Variable [ Name=l_linestatus ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_linestatus
+      ]
+      Variable [ Name=l_suppkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_suppkey
+      ]
+      With
+      Variable [ Name=l ]
+
+  )
+  AS
+  Variable [ Name=g ]
+]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=g ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=g ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=g ]
+
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/filter-nested.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/filter-nested.ast
new file mode 100644
index 0000000..dddcd69
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/filter-nested.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/filter-nested.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=lname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-dblp-csx.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-dblp-csx.ast
new file mode 100644
index 0000000..fe0b69c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-dblp-csx.ast
@@ -0,0 +1,200 @@
+DataverseUse fj-dblp-csx
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/fj-dblp-csx.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tokensDBLP]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tokensCSX]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=unrankedTokensDBLP ]
+  :=
+  FunctionCall fj-dblp-csx.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=unrankedTokensDBLP ]
+      AS
+      Variable [ Name=token ]
+,
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+        ]
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=token ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=unrankedTokensCSX ]
+  :=
+  FunctionCall fj-dblp-csx.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=unrankedTokensCSX ]
+      AS
+      Variable [ Name=token ]
+,
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+        ]
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=token ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Where
+  OperatorExpr [
+    Variable [ Name=prefixTokenDBLP ]
+    =
+    Variable [ Name=prefixTokenCSX ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  With
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=unrankedTokensCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=unrankedTokensDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-phase1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-phase1.ast
new file mode 100644
index 0000000..dc23607
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-phase1.ast
@@ -0,0 +1,111 @@
+DataverseUse rares03
+TypeDecl UserType [
+  open RecordType {
+    uid : int32,
+    name : string,
+    lottery_numbers : UnorderedList <int32>
+
+  }
+]
+TypeDecl VisitorType [
+  open RecordType {
+    vid : int32,
+    name : string,
+    lottery_numbers : UnorderedList <int32>
+
+  }
+]
+DatasetDecl Users(UserType) partitioned by [[uid]]
+DatasetDecl Visitors(VisitorType) partitioned by [[vid]]
+WriteOutputTo nc1:/tmp/rares03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [uid]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=uid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Users]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+LetVariable [ Name=tokens ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FieldAccessor [
+        Variable [ Name=user ]
+        Field=lottery_numbers
+      ]
+      AS
+      Variable [ Name=lottery_number ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=item ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Users]
+          ]
+          AS
+          Variable [ Name=user ]
+,
+          FieldAccessor [
+            Variable [ Name=user ]
+            Field=lottery_numbers
+          ]
+          AS
+          Variable [ Name=lottery_number ]
+        ]
+        Groupby
+          Variable [ Name=item ]
+          :=
+          Variable [ Name=lottery_number ]
+          With
+          Variable [ Name=lottery_number ]
+          Variable [ Name=user ]
+          Variable [ Name=lottery_number ]
+          Variable [ Name=tokens ]
+          Variable [ Name=user ]
+
+        LetVariable [ Name=count ]
+          :=
+          FunctionCall rares03.count@1[
+            Variable [ Name=user ]
+          ]
+        Orderby
+          Variable [ Name=count ]
+          DESC
+
+      )
+      AS
+      Variable [ Name=token ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=lottery_number ]
+        =
+        Variable [ Name=token ]
+      ]
+    Orderby
+      Variable [ Name=token ]
+      ASC
+
+  )
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-phase2-with-hints.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-phase2-with-hints.ast
new file mode 100644
index 0000000..48fcb34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/fj-phase2-with-hints.ast
@@ -0,0 +1,117 @@
+DataverseUse fuzzyjoin_078
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP_fuzzyjoin_078(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/fuzzyjoin_078.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP_fuzzyjoin_078]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=unrankedTokensDBLP ]
+  :=
+  FunctionCall fuzzyjoin_078.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=unrankedTokensDBLP ]
+      AS
+      Variable [ Name=token ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP_fuzzyjoin_078]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin_078.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=token ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=unrankedTokensDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin_078.count@1[
+            Variable [ Name=paper ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=token ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/hashjoin-with-unnest.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/hashjoin-with-unnest.ast
new file mode 100644
index 0000000..3432a40
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/hashjoin-with-unnest.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    name : string
+  }
+]
+DatasetDecl t1(TestType) partitioned by [[id]]
+DatasetDecl t2(TestType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/hahsjoin-with-unnest.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t1]
+    :
+    Variable [ Name=m ]
+  )
+  (
+    LiteralExpr [STRING] [t2]
+    :
+    Variable [ Name=n ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t1]
+  ]
+  AS
+  Variable [ Name=m ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t2]
+  ]
+  AS
+  Variable [ Name=n ]
+,
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=hobbies
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FieldAccessor [
+    Variable [ Name=n ]
+    Field=hobbies
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=a ]
+    =
+    Variable [ Name=b ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inline-funs.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inline-funs.ast
new file mode 100644
index 0000000..30ebc0b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inline-funs.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+WriteOutputTo nc1:/tmp/inline_funs.adm
+FunctionDecl f1([]) {
+  OperatorExpr [
+    LiteralExpr [LONG] [1]
+    +
+    FunctionCall test.f2@0[
+    ]
+  ]
+}
+
+FunctionDecl f2([]) {
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    +
+    FunctionCall test.f3@0[
+    ]
+    +
+    FunctionCall test.f3@0[
+    ]
+    +
+    FunctionCall test.f3@0[
+    ]
+    +
+    FunctionCall test.f4@0[
+    ]
+  ]
+}
+
+FunctionDecl f3([]) {
+  OperatorExpr [
+    LiteralExpr [LONG] [0]
+    -
+    LiteralExpr [LONG] [1]
+  ]
+}
+
+FunctionDecl f4([]) {
+  LiteralExpr [LONG] [1001]
+}
+
+Query:
+SELECT ELEMENT [
+FunctionCall test.f1@0[
+]
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inlined_q18_large_volume_customer.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inlined_q18_large_volume_customer.ast
new file mode 100644
index 0000000..ee6cc44
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inlined_q18_large_volume_customer.ast
@@ -0,0 +1,260 @@
+DataverseUse inlined_q18_large_volume_customer
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+DatasetDecl LineItems(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+WriteOutputTo nc1:/tmp/inlined_q18_large_volume_customer.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    Variable [ Name=o_orderkey ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    Variable [ Name=o_orderdate ]
+  )
+  (
+    LiteralExpr [STRING] [o_totalprice]
+    :
+    Variable [ Name=o_totalprice ]
+  )
+  (
+    LiteralExpr [STRING] [sum_quantity]
+    :
+    FunctionCall inlined_q18_large_volume_customer.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=j ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=j ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [t_sum_quantity]
+        :
+        FunctionCall inlined_q18_large_volume_customer.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_quantity
+            ]
+            ]
+            FROM [              Variable [ Name=l ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItems]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      With
+      Variable [ Name=l ]
+      Variable [ Name=c ]
+      Variable [ Name=o ]
+
+  )
+  AS
+  Variable [ Name=t ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItems]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_custkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=l_orderkey
+        ]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=t_sum_quantity
+        ]
+        >
+        LiteralExpr [LONG] [300]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_name
+  ]
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_custkey
+  ]
+  Variable [ Name=o_orderkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  Variable [ Name=o_orderdate ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderdate
+  ]
+  Variable [ Name=o_totalprice ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_totalprice
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=t ]
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=o_totalprice ]
+  DESC
+  Variable [ Name=o_orderdate ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [100]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-dataset-with-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-dataset-with-index.ast
new file mode 100644
index 0000000..0a65fca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-dataset-with-index.ast
@@ -0,0 +1,10 @@
+TypeDecl Emp [
+  closed RecordType {
+    id : int32,
+    fname : string,
+    lname : string,
+    age : int32,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-dataset.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-dataset.ast
new file mode 100644
index 0000000..705ff4e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-dataset.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl myDataType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl myData(myDataType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-joined-datasets.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-joined-datasets.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/insert-and-scan-joined-datasets.ast
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/introhashpartitionmerge.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/introhashpartitionmerge.ast
new file mode 100644
index 0000000..de52bd2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/introhashpartitionmerge.ast
@@ -0,0 +1,62 @@
+DataverseUse fuzzyjoin
+TypeDecl TOKENSRANKEDADMType [
+  closed RecordType {
+    token : int32,
+    rank : int32
+  }
+]
+DatasetDecl TOKENSRANKEDADM(TOKENSRANKEDADMType) partitioned by [[rank]]
+WriteOutputTo nc1:rttest/introhashpartitionmerge.adm
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=token2 ]
+  Field=rank
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TOKENSRANKEDADM]
+  ]
+  AS
+  Variable [ Name=token1 ]
+,
+  (
+    SELECT ELEMENT [
+    Variable [ Name=tokenRanked ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [TOKENSRANKEDADM]
+      ]
+      AS
+      Variable [ Name=tokenRanked ]
+    ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=tokenRanked ]
+        Field=rank
+      ]
+      ASC
+
+  )
+  AS
+  Variable [ Name=token2 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=token1 ]
+      Field=token
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=token2 ]
+      Field=token
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=token2 ]
+    Field=rank
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-contains-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-contains-panic.ast
new file mode 100644
index 0000000..5e06222
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-contains-panic.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Mu]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-contains.ast
new file mode 100644
index 0000000..ee9ee67
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-contains.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-check-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-check-panic.ast
new file mode 100644
index 0000000..80ed456
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-check-panic.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-check.ast
new file mode 100644
index 0000000..8ba659b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-check.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-panic.ast
new file mode 100644
index 0000000..5b32107
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance-panic.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance.ast
new file mode 100644
index 0000000..d01be8c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-edit-distance.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..a5ec0cd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    ~=
+    LiteralExpr [STRING] [Amihay Motro]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..e3be774
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    ~=
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-jaccard-check.ast
new file mode 100644
index 0000000..3a2e43d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-jaccard-check.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-jaccard.ast
new file mode 100644
index 0000000..dfc2b78
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ngram-jaccard.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-check-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-check-panic.ast
new file mode 100644
index 0000000..6137ce8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-check-panic.ast
@@ -0,0 +1,70 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance-check-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [3]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [3]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-check.ast
new file mode 100644
index 0000000..e893033
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-check.ast
@@ -0,0 +1,70 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-panic.ast
new file mode 100644
index 0000000..8d4d941
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance-panic.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+    ]
+    <=
+    LiteralExpr [LONG] [3]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance.ast
new file mode 100644
index 0000000..211767c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-edit-distance.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+    ]
+    <=
+    LiteralExpr [LONG] [1]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..5939747
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-fuzzyeq-edit-distance.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    ~=
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..8911b28
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-fuzzyeq-jaccard.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    ~=
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-jaccard-check.ast
new file mode 100644
index 0000000..6df827e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-jaccard-check.ast
@@ -0,0 +1,63 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-jaccard.ast
new file mode 100644
index 0000000..520eaa3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/olist-jaccard.ast
@@ -0,0 +1,52 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.7]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..f9a8f63
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-fuzzyeq-jaccard.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ulist-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    ~=
+    UnorderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [databases]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-jaccard-check.ast
new file mode 100644
index 0000000..352c27b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-jaccard-check.ast
@@ -0,0 +1,63 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ulist-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      UnorderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [databases]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      UnorderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [databases]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-jaccard.ast
new file mode 100644
index 0000000..437e2d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/ulist-jaccard.ast
@@ -0,0 +1,52 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ulist-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=interests
+      ]
+      UnorderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [wine]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.7]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-contains.ast
new file mode 100644
index 0000000..ff2ec88
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-contains.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..b2b87af
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-fuzzyeq-jaccard.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-jaccard-check.ast
new file mode 100644
index 0000000..721ba2f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-jaccard-check.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-jaccard.ast
new file mode 100644
index 0000000..d79a75b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-basic/word-jaccard.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
new file mode 100644
index 0000000..7fd4d5e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
new file mode 100644
index 0000000..ed8919f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
new file mode 100644
index 0000000..0c3a146
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let.ast
new file mode 100644
index 0000000..e33ade2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-let.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-substring.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-substring.ast
new file mode 100644
index 0000000..c02435c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-substring.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
new file mode 100644
index 0000000..8b24f37
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-jaccard-check-let.ast
new file mode 100644
index 0000000..fe5751b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-jaccard-check-let.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..a2ce996
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ngram-jaccard-check-multi-let.ast
@@ -0,0 +1,63 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-edit-distance-check-let-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-edit-distance-check-let-panic.ast
new file mode 100644
index 0000000..d37e489
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-edit-distance-check-let-panic.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_olist-edit-distance-check-let-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-edit-distance-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-edit-distance-check-let.ast
new file mode 100644
index 0000000..21b8dbb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-edit-distance-check-let.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_olist-edit-distance-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-jaccard-check-let.ast
new file mode 100644
index 0000000..3bd622b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/olist-jaccard-check-let.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_olist-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ulist-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ulist-jaccard-check-let.ast
new file mode 100644
index 0000000..f0bf820
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/ulist-jaccard-check-let.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ulist-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/word-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/word-jaccard-check-let.ast
new file mode 100644
index 0000000..6e32d34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/word-jaccard-check-let.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/word-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/word-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..22ccaf9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-complex/word-jaccard-check-multi-let.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline.ast
new file mode 100644
index 0000000..8084f98
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aauthors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bauthors]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance.ast
new file mode 100644
index 0000000..622f47d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-edit-distance.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aauthors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bauthors]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..6e84dfe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-edit-distance.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aauthors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bauthors]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..8de8a42
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-fuzzyeq-jaccard.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline.ast
new file mode 100644
index 0000000..c2b429a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline.ast
@@ -0,0 +1,91 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard.ast
new file mode 100644
index 0000000..dd52bc7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-jaccard.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline.ast
new file mode 100644
index 0000000..df3ec56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline.ast
@@ -0,0 +1,96 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-edit-distance-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance.ast
new file mode 100644
index 0000000..109ff0e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance.ast
@@ -0,0 +1,89 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-edit-distance.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..e7b7618
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-edit-distance.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..72546e5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-fuzzyeq-jaccard.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline.ast
new file mode 100644
index 0000000..0979b76
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline.ast
@@ -0,0 +1,96 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard.ast
new file mode 100644
index 0000000..df0821c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard.ast
@@ -0,0 +1,89 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-jaccard.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..9030aa4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-fuzzyeq-jaccard.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ulist-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline.ast
new file mode 100644
index 0000000..3a54439
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline.ast
@@ -0,0 +1,96 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ulist-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard.ast
new file mode 100644
index 0000000..b5cd01b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard.ast
@@ -0,0 +1,89 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ulist-jaccard.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..2bbfbba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-fuzzyeq-jaccard.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_word-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline.ast
new file mode 100644
index 0000000..15c16da
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard.ast
new file mode 100644
index 0000000..5c5083b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_word-jaccard.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/issue741.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/issue741.ast
new file mode 100644
index 0000000..25459dc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/issue741.ast
@@ -0,0 +1,117 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen_name : string,
+    lang : string,
+    friends_count : int32,
+    statuses_count : int32,
+    name : string,
+    followers_count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender_location : point?,
+    send_time : datetime,
+    referred_topics : UnorderedList <string>
+,
+    message_text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_issue741.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=tweetid
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.similarity-jaccard-check@3[
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=referred_topics
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=referred_topics
+          ]
+          LiteralExpr [FLOAT] [0.6]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t ]
+              Field=tweetid
+            ]
+          ]
+        ]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=send_time
+      ]
+      >=
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-06-18T14:10:17]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=send_time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-06-18T15:10:17]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
new file mode 100644
index 0000000..a3b4ee5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
@@ -0,0 +1,148 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.ast
new file mode 100644
index 0000000..d280beb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.ast
@@ -0,0 +1,148 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-jaccard-check_idx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=referred-topics
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=referred-topics
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.similarity-jaccard-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=referred-topics
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=referred-topics
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-contains.ast
new file mode 100644
index 0000000..a704add
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-contains.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_01.ast
new file mode 100644
index 0000000..fe0a5ae
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_01.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_02.ast
new file mode 100644
index 0000000..226ef2da
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_02.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_03.ast
new file mode 100644
index 0000000..22a1b5c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_03.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_04.ast
new file mode 100644
index 0000000..5dd91f7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-check_04.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    IndexAccessor [
+      Variable [ Name=ed ]
+      Index:       Variable [ Name=ed ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=ed ]
+      Index:       Variable [ Name=ed ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-contains.ast
new file mode 100644
index 0000000..2f33777
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-contains.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-contains.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_01.ast
new file mode 100644
index 0000000..0bb1cc1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_01.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_02.ast
new file mode 100644
index 0000000..c558c56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_02.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_03.ast
new file mode 100644
index 0000000..cbe7ead
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_03.ast
@@ -0,0 +1,68 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_04.ast
new file mode 100644
index 0000000..1b28c62
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-edit-distance_04.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
new file mode 100644
index 0000000..d9572ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast
new file mode 100644
index 0000000..d9572ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast
new file mode 100644
index 0000000..c8abd1e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_03.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..6acee19
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..23cc11f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_02.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..ba8bc3a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_03.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_01.ast
new file mode 100644
index 0000000..d0217af
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_01.ast
@@ -0,0 +1,105 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_02.ast
new file mode 100644
index 0000000..0fd14a4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_02.ast
@@ -0,0 +1,105 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_03.ast
new file mode 100644
index 0000000..b816313
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_03.ast
@@ -0,0 +1,95 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_04.ast
new file mode 100644
index 0000000..4695a2c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard-check_04.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_01.ast
new file mode 100644
index 0000000..c20a176
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_01.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_02.ast
new file mode 100644
index 0000000..e15dd73
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_02.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_03.ast
new file mode 100644
index 0000000..508f374
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_03.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_04.ast
new file mode 100644
index 0000000..2683356
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ngram-jaccard_04.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_01.ast
new file mode 100644
index 0000000..50e0cac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_01.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_02.ast
new file mode 100644
index 0000000..a0714e9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_02.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_03.ast
new file mode 100644
index 0000000..c76a987
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_03.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_04.ast
new file mode 100644
index 0000000..da43e50
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance-check_04.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    IndexAccessor [
+      Variable [ Name=ed ]
+      Index:       Variable [ Name=ed ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=ed ]
+      Index:       Variable [ Name=ed ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_01.ast
new file mode 100644
index 0000000..ea73b1d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_01.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_02.ast
new file mode 100644
index 0000000..cd6030b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_02.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_03.ast
new file mode 100644
index 0000000..47bb197
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_03.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_04.ast
new file mode 100644
index 0000000..497a7bc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-edit-distance_04.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_01.ast
new file mode 100644
index 0000000..5c2bb68
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_01.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_02.ast
new file mode 100644
index 0000000..e5041c2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_02.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_02.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_03.ast
new file mode 100644
index 0000000..50a6766
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-edit-distance_03.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_03.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..6867b1f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..f73f475
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_02.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..a460848
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_03.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_01.ast
new file mode 100644
index 0000000..6047077
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_01.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_02.ast
new file mode 100644
index 0000000..201c5b1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_02.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_03.ast
new file mode 100644
index 0000000..2b79710
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_03.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_04.ast
new file mode 100644
index 0000000..e54b565
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard-check_04.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_01.ast
new file mode 100644
index 0000000..c4c53e9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_01.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_02.ast
new file mode 100644
index 0000000..e9bc194
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_02.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_03.ast
new file mode 100644
index 0000000..49df027
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_03.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_04.ast
new file mode 100644
index 0000000..ad23eb3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/olist-jaccard_04.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..26d202c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..d4a74e6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-fuzzyeq-jaccard_02.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..6e2bc46
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-fuzzyeq-jaccard_03.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_01.ast
new file mode 100644
index 0000000..5522ff1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_01.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_02.ast
new file mode 100644
index 0000000..ad4806a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_02.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_03.ast
new file mode 100644
index 0000000..fe395ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_03.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_04.ast
new file mode 100644
index 0000000..20a87d3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard-check_04.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_01.ast
new file mode 100644
index 0000000..19e7e50
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_01.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_02.ast
new file mode 100644
index 0000000..fe480c0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_02.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_03.ast
new file mode 100644
index 0000000..0d86200
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_03.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_04.ast
new file mode 100644
index 0000000..fa078f8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/ulist-jaccard_04.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..471fc0d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..6754b52
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_02.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..880a2c6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,71 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_03.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check-after-btree-access.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check-after-btree-access.ast
new file mode 100644
index 0000000..5b4c193
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check-after-btree-access.ast
@@ -0,0 +1,114 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2]
+    :
+    FieldAccessor [
+      Variable [ Name=t2 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t2 ]
+]
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=message-text
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=message-text
+      ]
+    ]
+    LiteralExpr [FLOAT] [0.6]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=tweetid
+      ]
+      <
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=tweetid
+      ]
+      !=
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=tweetid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_01.ast
new file mode 100644
index 0000000..6586148
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_01.ast
@@ -0,0 +1,96 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_02.ast
new file mode 100644
index 0000000..0b50ff8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_02.ast
@@ -0,0 +1,96 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_03.ast
new file mode 100644
index 0000000..3c74848
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_03.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_04.ast
new file mode 100644
index 0000000..711c89a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard-check_04.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_01.ast
new file mode 100644
index 0000000..9c3199f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_01.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_02.ast
new file mode 100644
index 0000000..e8f2e5b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_02.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_03.ast
new file mode 100644
index 0000000..58e6be6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_03.ast
@@ -0,0 +1,72 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_04.ast
new file mode 100644
index 0000000..f1fc7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/inverted-index-join/word-jaccard_04.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/join-super-key_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/join-super-key_01.ast
new file mode 100644
index 0000000..ac3d0bc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/join-super-key_01.ast
@@ -0,0 +1,128 @@
+DataverseUse join-super-key_1
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+WriteOutputTo nc1:/tmp/join-super-key_01.adm
+DatasetDecl LineItems(LineItemType) partitioned by [[l_partkey], [l_linenumber]]
+DatasetDecl PartSupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=li ]
+      Field=l_partkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItems]
+  ]
+  AS
+  Variable [ Name=li ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [PartSupp]
+  ]
+  AS
+  Variable [ Name=ps ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=li ]
+        Field=l_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_partkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=li ]
+        Field=l_suppkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_suppkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=li ]
+        Field=l_extendedprice
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_supplycost
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/join-super-key_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/join-super-key_02.ast
new file mode 100644
index 0000000..e2ed7f3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/join-super-key_02.ast
@@ -0,0 +1,128 @@
+DataverseUse join-super-key_01
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+WriteOutputTo nc1:/tmp/join-super-key_01.adm
+DatasetDecl LineItems(LineItemType) partitioned by [[l_partkey], [l_linenumber]]
+DatasetDecl PartSupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=li ]
+      Field=l_partkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [PartSupp]
+  ]
+  AS
+  Variable [ Name=ps ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItems]
+  ]
+  AS
+  Variable [ Name=li ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=li ]
+        Field=l_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_partkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=li ]
+        Field=l_suppkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_suppkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=li ]
+        Field=l_extendedprice
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_supplycost
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/limit-issue353.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/limit-issue353.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/limit-issue353.ast
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/loj-super-key_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/loj-super-key_01.ast
new file mode 100644
index 0000000..183c8a7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/loj-super-key_01.ast
@@ -0,0 +1,137 @@
+DataverseUse loj-super-key_01
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+WriteOutputTo nc1:/tmp/loj-super-key_01.adm
+DatasetDecl LineItems(LineItemType) partitioned by [[l_partkey], [l_linenumber]]
+DatasetDecl PartSupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [li]
+    :
+    Variable [ Name=li ]
+  )
+  (
+    LiteralExpr [STRING] [partsupp]
+    :
+    Variable [ Name=partsupp ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItems]
+  ]
+  AS
+  Variable [ Name=li ]
+]
+LetVariable [ Name=partsupp ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=ps ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [PartSupp]
+      ]
+      AS
+      Variable [ Name=ps ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=li ]
+            Field=l_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=li ]
+            Field=l_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_suppkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=li ]
+            Field=l_extendedprice
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_supplycost
+          ]
+        ]
+      ]
+  )
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/loj-super-key_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/loj-super-key_02.ast
new file mode 100644
index 0000000..f78a47f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/loj-super-key_02.ast
@@ -0,0 +1,137 @@
+DataverseUse loj-super-key_02
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+WriteOutputTo nc1:/tmp/loj-super-key_01.adm
+DatasetDecl LineItems(LineItemType) partitioned by [[l_partkey], [l_linenumber]]
+DatasetDecl PartSupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partsupp]
+    :
+    Variable [ Name=ps ]
+  )
+  (
+    LiteralExpr [STRING] [li]
+    :
+    Variable [ Name=items ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [PartSupp]
+  ]
+  AS
+  Variable [ Name=ps ]
+]
+LetVariable [ Name=items ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=li ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItems]
+      ]
+      AS
+      Variable [ Name=li ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=li ]
+            Field=l_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=li ]
+            Field=l_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_suppkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=li ]
+            Field=l_extendedprice
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_supplycost
+          ]
+        ]
+      ]
+  )
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nest_aggregate.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nest_aggregate.ast
new file mode 100644
index 0000000..1556199
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nest_aggregate.ast
@@ -0,0 +1,220 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [aggregates]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [order_date]
+          :
+          Variable [ Name=orderdate ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          Variable [ Name=sum ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Orders]
+        ]
+        AS
+        Variable [ Name=orders ]
+,
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=customer ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=orders ]
+              Field=o_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_custkey
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_nationkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=nation ]
+              Field=n_nationkey
+            ]
+          ]
+        ]
+      Groupby
+        Variable [ Name=orderdate ]
+        :=
+        FieldAccessor [
+          Variable [ Name=orders ]
+          Field=o_orderdate
+        ]
+        With
+        Variable [ Name=orders ]
+        Variable [ Name=customer ]
+        Variable [ Name=nation ]
+        Variable [ Name=sn ]
+
+      LetVariable [ Name=sum ]
+        :=
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_totalprice
+            ]
+            ]
+            FROM [              Variable [ Name=orders ]
+              AS
+              Variable [ Name=o ]
+            ]
+          )
+        ]
+      Orderby
+        Variable [ Name=sum ]
+        ASC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Nation]
+  ]
+  AS
+  Variable [ Name=nation ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [SelectedNation]
+  ]
+  AS
+  Variable [ Name=sn ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=sn ]
+      Field=n_nationkey
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/disjunction-to-join.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/disjunction-to-join.ast
new file mode 100644
index 0000000..ed8e12c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/disjunction-to-join.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+TypeDecl NestedTestType [
+  open RecordType {
+    idx : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    no-idx : string,
+    nested : NestedTestType
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=nested
+        ]
+        Field=idx
+      ]
+      =
+      LiteralExpr [STRING] [one]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=nested
+        ]
+        Field=idx
+      ]
+      =
+      LiteralExpr [STRING] [two]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.ast
new file mode 100644
index 0000000..a80969f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01.ast
@@ -0,0 +1,154 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.ast
new file mode 100644
index 0000000..9cd8ca9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02.ast
@@ -0,0 +1,174 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_01.ast
new file mode 100644
index 0000000..2ef7739
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_01.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_02.ast
new file mode 100644
index 0000000..ca30680
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_02.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_03.ast
new file mode 100644
index 0000000..2532b97
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-join_03.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_01.ast
new file mode 100644
index 0000000..69c2080
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_01.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_02.ast
new file mode 100644
index 0000000..ad60381
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_02.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_03.ast
new file mode 100644
index 0000000..eb2a8ea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_03.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_04.ast
new file mode 100644
index 0000000..5954689
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_04.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_05.ast
new file mode 100644
index 0000000..60d0d3f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_05.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_06.ast
new file mode 100644
index 0000000..7bb68ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-composite-key-prefix-join_06.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl Name [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(Name) partitioned by [[nested, fname], [nested, lname]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-composite-key-prefix-prefix-join_06.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join-multipred.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join-multipred.ast
new file mode 100644
index 0000000..c18bfa1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join-multipred.ast
@@ -0,0 +1,133 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, oid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join-multipred.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=name
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=orderstatus
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=age
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join-neg_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join-neg_01.ast
new file mode 100644
index 0000000..18e2cca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join-neg_01.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join-neg_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_01.ast
new file mode 100644
index 0000000..0b0dee7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_01.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_02.ast
new file mode 100644
index 0000000..dda0c74
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_02.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_03.ast
new file mode 100644
index 0000000..f7fe80e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_03.ast
@@ -0,0 +1,95 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, oid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_04.ast
new file mode 100644
index 0000000..73cd664
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_04.ast
@@ -0,0 +1,95 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, oid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_05.ast
new file mode 100644
index 0000000..6938c8c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-equi-join_05.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-equi-join_06.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customer1]
+    :
+    FieldAccessor [
+      Variable [ Name=c1 ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [customer2]
+    :
+    FieldAccessor [
+      Variable [ Name=c2 ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c2 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c1 ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c2 ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-ge-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-ge-join_01.ast
new file mode 100644
index 0000000..abfb347
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-ge-join_01.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-ge-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+    >=
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-gt-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-gt-join_01.ast
new file mode 100644
index 0000000..bc91d4c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-gt-join_01.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-gt-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+    >
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-le-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-le-join_01.ast
new file mode 100644
index 0000000..454e159
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-le-join_01.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-le-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+    <=
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-lt-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-lt-join_01.ast
new file mode 100644
index 0000000..4aa9cc3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/primary-lt-join_01.ast
@@ -0,0 +1,50 @@
+TypeDecl TestTypetmp [
+  open RecordType {
+    key1 : int32,
+    key2 : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl DsOne(TestType) partitioned by [[nested, key1]]
+DatasetDecl DsTwo(TestType) partitioned by [[nested, key1]]
+WriteOutputTo nc1:rttest/btree-index-join_primary-lt-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsOne]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.DsTwo]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=nested
+      ]
+      Field=key1
+    ]
+    <
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=y ]
+        Field=nested
+      ]
+      Field=key2
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join-multiindex.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join-multiindex.ast
new file mode 100644
index 0000000..570a02a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join-multiindex.ast
@@ -0,0 +1,151 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  closed RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserTypetmp [
+  closed RecordType {
+    id : int32,
+    id-copy : int32,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    user-since-copy : datetime,
+    friend-ids : UnorderedList <int32>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageTypetmp [
+  closed RecordType {
+    message-id : int32,
+    message-id-copy : int32,
+    author-id : int32,
+    author-id-copy : int32,
+    in-response-to : int32?,
+    sender-location : point?,
+    message : string
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    nested : FacebookUserTypetmp
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    nested : FacebookMessageTypetmp
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[nested, id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[nested, message-id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multiindex.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [fbu-ID]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fbm-auth-ID]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=nested
+      ]
+      Field=author-id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=nested
+      ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=nested
+      ]
+      Field=message
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=message ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=message ]
+          Field=nested
+        ]
+        Field=author-id-copy
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      >=
+      LiteralExpr [LONG] [11000]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <=
+      LiteralExpr [LONG] [12000]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join-multipred.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join-multipred.ast
new file mode 100644
index 0000000..6819318
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join-multipred.ast
@@ -0,0 +1,115 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multipred.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=misc
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=misc
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join_01.ast
new file mode 100644
index 0000000..9ce15ed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index-join/secondary-equi-join_01.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-01.ast
new file mode 100644
index 0000000..42ce16e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-01.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-01.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-02.ast
new file mode 100644
index 0000000..f360b93
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-02.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-02.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Susan]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-03.ast
new file mode 100644
index 0000000..0b84e43
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-03.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-03.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Isa]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-04.ast
new file mode 100644
index 0000000..00b3e5f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-04.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-04.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Vanpatten]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-05.ast
new file mode 100644
index 0000000..13c7a0c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-05.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-05.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    !=
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-06.ast
new file mode 100644
index 0000000..22b4a09
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-06.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-06.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-07.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-07.ast
new file mode 100644
index 0000000..d7ce1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-07.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-07.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=lname
+    ]
+    =
+    LiteralExpr [STRING] [Kim]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-08.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-08.ast
new file mode 100644
index 0000000..f3b2650
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-08.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-08.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Young Seok]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Kim]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-09.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-09.ast
new file mode 100644
index 0000000..fdb6714
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-09.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-09.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Malaika]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-10.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-10.ast
new file mode 100644
index 0000000..b5d84d9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-10.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-10.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Alex]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zach]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-11.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-11.ast
new file mode 100644
index 0000000..af3babb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-11.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-11.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zubi]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-12.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-12.ast
new file mode 100644
index 0000000..2f631d6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-12.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-12.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-13.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-13.ast
new file mode 100644
index 0000000..216fed4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-13.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-13.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-14.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-14.ast
new file mode 100644
index 0000000..ee2ff97
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-14.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-14.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-15.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-15.ast
new file mode 100644
index 0000000..717f5ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-15.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-15.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-16.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-16.ast
new file mode 100644
index 0000000..5dffd6f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-16.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-16.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-17.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-17.ast
new file mode 100644
index 0000000..e4ed6d6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-17.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-17.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-18.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-18.ast
new file mode 100644
index 0000000..6d3e3ea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-18.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-18.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=emp ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      !=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      !=
+      LiteralExpr [STRING] [Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-19.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-19.ast
new file mode 100644
index 0000000..ed5c69e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-19.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-19.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-20.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-20.ast
new file mode 100644
index 0000000..a9077eb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-20.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-20.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-21.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-21.ast
new file mode 100644
index 0000000..5d9f8650
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-21.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-21.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-22.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-22.ast
new file mode 100644
index 0000000..27f522c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-22.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-22.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Sofia]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-23.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-23.ast
new file mode 100644
index 0000000..2991c8f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-23.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-23.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Chen]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-24.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-24.ast
new file mode 100644
index 0000000..7ddd5a3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-24.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-24.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-25.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-25.ast
new file mode 100644
index 0000000..5d7aa47
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-25.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-25.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Neil]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-26.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-26.ast
new file mode 100644
index 0000000..ce501f9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-26.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-26.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-27.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-27.ast
new file mode 100644
index 0000000..8d1be46
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-27.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-27.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-28.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-28.ast
new file mode 100644
index 0000000..e5ced5a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-28.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-28.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-29.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-29.ast
new file mode 100644
index 0000000..c587956
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-29.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-29.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-30.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-30.ast
new file mode 100644
index 0000000..232c6e4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-30.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-30.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-31.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-31.ast
new file mode 100644
index 0000000..1809232
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-31.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-31.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-32.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-32.ast
new file mode 100644
index 0000000..e7ad65c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-primary-32.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-32.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, fname], [nested, lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-33.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-33.ast
new file mode 100644
index 0000000..7889023
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-33.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-31.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-34.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-34.ast
new file mode 100644
index 0000000..990799e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-34.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-32.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Susan]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-35.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-35.ast
new file mode 100644
index 0000000..b05f885
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-35.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-33.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Isa]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-36.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-36.ast
new file mode 100644
index 0000000..5f9d594
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-36.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-34.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Vanpatten]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-37.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-37.ast
new file mode 100644
index 0000000..a0696dd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-37.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-35.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    !=
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-38.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-38.ast
new file mode 100644
index 0000000..a5433da
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-38.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-36.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-39.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-39.ast
new file mode 100644
index 0000000..594198a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-39.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-37.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=lname
+    ]
+    =
+    LiteralExpr [STRING] [Kim]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-40.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-40.ast
new file mode 100644
index 0000000..565be07
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-40.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-38.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Young Seok]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Kim]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-41.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-41.ast
new file mode 100644
index 0000000..18c3e40
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-41.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-39.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Malaika]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-42.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-42.ast
new file mode 100644
index 0000000..1a85c82
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-42.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-40.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Alex]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zach]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-43.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-43.ast
new file mode 100644
index 0000000..a5f5d1b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-43.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-41.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zubi]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-44.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-44.ast
new file mode 100644
index 0000000..ac2f9db
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-44.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-42.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-45.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-45.ast
new file mode 100644
index 0000000..599c307
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-45.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-43.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-46.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-46.ast
new file mode 100644
index 0000000..fc37fd3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-46.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-44.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-47.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-47.ast
new file mode 100644
index 0000000..e46e858
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-47.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-45.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-48.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-48.ast
new file mode 100644
index 0000000..c3e6c2c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-48.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-46.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-49.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-49.ast
new file mode 100644
index 0000000..bea229d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-49.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-47.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-50.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-50.ast
new file mode 100644
index 0000000..13c5526
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-50.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-48.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      !=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      !=
+      LiteralExpr [STRING] [Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-51.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-51.ast
new file mode 100644
index 0000000..3dcb983
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-51.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-49.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-52.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-52.ast
new file mode 100644
index 0000000..d7c1d4b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-52.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-50.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-53.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-53.ast
new file mode 100644
index 0000000..5af903b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-53.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-51.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-54.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-54.ast
new file mode 100644
index 0000000..fa7becf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-54.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-52.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-55.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-55.ast
new file mode 100644
index 0000000..d537f37
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-55.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-53.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Sofia]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-56.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-56.ast
new file mode 100644
index 0000000..aa88dcf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-56.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-54.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Chen]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-57.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-57.ast
new file mode 100644
index 0000000..cf3bf3e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-57.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-55.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-58.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-58.ast
new file mode 100644
index 0000000..86754e6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-58.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-56.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Neil]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-59.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-59.ast
new file mode 100644
index 0000000..692abda
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-59.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-57.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-60.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-60.ast
new file mode 100644
index 0000000..113897d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-60.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-58.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-61.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-61.ast
new file mode 100644
index 0000000..d2b1557
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-61.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-61.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-62.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-62.ast
new file mode 100644
index 0000000..e7c31f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-62.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-62.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-63.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-63.ast
new file mode 100644
index 0000000..c5c5f2a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/btree-index/btree-secondary-63.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-63.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-contains-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-contains-panic.ast
new file mode 100644
index 0000000..3ec89da
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-contains-panic.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Mu]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-contains.ast
new file mode 100644
index 0000000..1f56127
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-contains.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.ast
new file mode 100644
index 0000000..fb96e6c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check.ast
new file mode 100644
index 0000000..cab1fc3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-check.ast
@@ -0,0 +1,52 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-panic.ast
new file mode 100644
index 0000000..ac106b9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance-panic.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance.ast
new file mode 100644
index 0000000..03a8300
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-edit-distance.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..3008416
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    ~=
+    LiteralExpr [STRING] [Amihay Motro]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..012956a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    ~=
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-jaccard-check.ast
new file mode 100644
index 0000000..a62993b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-jaccard-check.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-jaccard.ast
new file mode 100644
index 0000000..d4b8bdc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ngram-jaccard.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check-panic.ast
new file mode 100644
index 0000000..c4b3feb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check-panic.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance-check-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [3]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [3]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check.ast
new file mode 100644
index 0000000..49cb6f6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-check.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-panic.ast
new file mode 100644
index 0000000..16f1b3f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance-panic.ast
@@ -0,0 +1,71 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+    ]
+    <=
+    LiteralExpr [LONG] [3]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance.ast
new file mode 100644
index 0000000..7acd8c0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-edit-distance.ast
@@ -0,0 +1,71 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-edit-distance.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [walking]
+      ]
+    ]
+    <=
+    LiteralExpr [LONG] [1]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..0e5a6b4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    ~=
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..b4fc19f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    ~=
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-jaccard-check.ast
new file mode 100644
index 0000000..c5d132d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-jaccard-check.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-jaccard.ast
new file mode 100644
index 0000000..798117d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/olist-jaccard.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_olist-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      OrderedListConstructor [
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.7]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..3987c49
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ulist-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    ~=
+    UnorderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [databases]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-jaccard-check.ast
new file mode 100644
index 0000000..6d2fa02
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-jaccard-check.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ulist-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      UnorderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [databases]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      UnorderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [wine]
+        LiteralExpr [STRING] [databases]
+      ]
+      LiteralExpr [FLOAT] [0.7]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-jaccard.ast
new file mode 100644
index 0000000..ed90e64
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/ulist-jaccard.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ulist-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      UnorderedListConstructor [
+        LiteralExpr [STRING] [computers]
+        LiteralExpr [STRING] [databases]
+        LiteralExpr [STRING] [wine]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.7]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-contains.ast
new file mode 100644
index 0000000..fd54f12
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-contains.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..ad20927
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-jaccard-check.ast
new file mode 100644
index 0000000..a56a462
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-jaccard-check.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-jaccard.ast
new file mode 100644
index 0000000..01ed330
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-basic/word-jaccard.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
new file mode 100644
index 0000000..6440f7e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
@@ -0,0 +1,65 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
new file mode 100644
index 0000000..a3648fe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
@@ -0,0 +1,65 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
new file mode 100644
index 0000000..9e51d97
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let.ast
new file mode 100644
index 0000000..025aa20
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-let.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.ast
new file mode 100644
index 0000000..83c6b9b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
new file mode 100644
index 0000000..4108c72
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-let.ast
new file mode 100644
index 0000000..1fe0c3a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-let.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..e772f9f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.ast
@@ -0,0 +1,71 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let-panic.ast
new file mode 100644
index 0000000..d54ef57
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let-panic.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_olist-edit-distance-check-let-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let.ast
new file mode 100644
index 0000000..29ce26d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-edit-distance-check-let.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_olist-edit-distance-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-jaccard-check-let.ast
new file mode 100644
index 0000000..6fe8f83
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/olist-jaccard-check-let.ast
@@ -0,0 +1,63 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_olist-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ulist-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ulist-jaccard-check-let.ast
new file mode 100644
index 0000000..ba67057
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/ulist-jaccard-check-let.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ulist-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-let.ast
new file mode 100644
index 0000000..48e978f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-let.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..a6c08fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-complex/word-jaccard-check-multi-let.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
new file mode 100644
index 0000000..cadc921
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
@@ -0,0 +1,186 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.ast
new file mode 100644
index 0000000..a698a84
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-jaccard-check-idx_01.ast
@@ -0,0 +1,186 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-jaccard-check_idx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=referred-topics
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=referred-topics
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.similarity-jaccard-check@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=referred-topics
+          ]
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=referred-topics
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-check_01.ast
new file mode 100644
index 0000000..088d1ec
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-check_01.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-contains.ast
new file mode 100644
index 0000000..24ca38a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-contains.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-contains.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-inline.ast
new file mode 100644
index 0000000..86cc4e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance-inline.ast
@@ -0,0 +1,105 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aauthors]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bauthors]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance_01.ast
new file mode 100644
index 0000000..c9fe10c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-edit-distance_01.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
new file mode 100644
index 0000000..f477597
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..ca69c0d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard-check_01.ast
new file mode 100644
index 0000000..852ddc8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard-check_01.ast
@@ -0,0 +1,133 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard-inline.ast
new file mode 100644
index 0000000..7d0cefb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard-inline.ast
@@ -0,0 +1,114 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard_01.ast
new file mode 100644
index 0000000..9a0270a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ngram-jaccard_01.ast
@@ -0,0 +1,109 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance-check_01.ast
new file mode 100644
index 0000000..7cc0e31
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance-check_01.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance-inline.ast
new file mode 100644
index 0000000..754a451
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance-inline.ast
@@ -0,0 +1,120 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-edit-distance-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance_01.ast
new file mode 100644
index 0000000..ea5e34c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-edit-distance_01.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-edit-distance_01.ast
new file mode 100644
index 0000000..8c088c3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-edit-distance_01.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..8b5badc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard-check_01.ast
new file mode 100644
index 0000000..280f534
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard-check_01.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard-inline.ast
new file mode 100644
index 0000000..bb60c12
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard-inline.ast
@@ -0,0 +1,120 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_olist-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard_01.ast
new file mode 100644
index 0000000..e281004
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/olist-jaccard_01.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_olist-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..07274a1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.7f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=interests
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard-check_01.ast
new file mode 100644
index 0000000..2f0cb06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard-check_01.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        LiteralExpr [FLOAT] [0.7]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard-inline.ast
new file mode 100644
index 0000000..30ee3fc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard-inline.ast
@@ -0,0 +1,120 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ulist-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ainterests]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binterests]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard_01.ast
new file mode 100644
index 0000000..a41eba6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/ulist-jaccard_01.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
+WriteOutputTo nc1:rttest/inverted-index-join_ulist-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.7]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..f82fb83
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-check-after-btree-access.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-check-after-btree-access.ast
new file mode 100644
index 0000000..317caba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-check-after-btree-access.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t2 ]
+]
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=nested
+        ]
+        Field=message-text
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=nested
+        ]
+        Field=message-text
+      ]
+    ]
+    LiteralExpr [FLOAT] [0.6]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=nested
+        ]
+        Field=tweetid
+      ]
+      <
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=nested
+        ]
+        Field=tweetid
+      ]
+      !=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=nested
+        ]
+        Field=tweetid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-check_01.ast
new file mode 100644
index 0000000..6daba98
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-check_01.ast
@@ -0,0 +1,124 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-inline.ast
new file mode 100644
index 0000000..36a5db9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard-inline.ast
@@ -0,0 +1,109 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard_01.ast
new file mode 100644
index 0000000..459bc81
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/inverted-index-join/word-jaccard_01.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
new file mode 100644
index 0000000..2bdd565d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
@@ -0,0 +1,156 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
new file mode 100644
index 0000000..c42875a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
@@ -0,0 +1,179 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_01.ast
new file mode 100644
index 0000000..3698698
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_01.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordNested [
+  closed RecordType {
+    nested : MyRecord
+  }
+]
+DatasetDecl MyData1(MyRecordNested) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index-join_rtree-spatial-intersect-point.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_02.ast
new file mode 100644
index 0000000..e270746
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_02.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordNested [
+  closed RecordType {
+    nested : MyRecord
+  }
+]
+DatasetDecl MyData1(MyRecordNested) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_03.ast
new file mode 100644
index 0000000..2b58875
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-index/rtree-index-join/spatial-intersect-point_03.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordNested [
+  closed RecordType {
+    nested : MyRecord
+  }
+]
+DatasetDecl MyData(MyRecordNested) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/disjunction-to-join.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/disjunction-to-join.ast
new file mode 100644
index 0000000..e53eac9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/disjunction-to-join.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+TypeDecl NestedTestType [
+  open RecordType {
+
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    no-idx : string,
+    nested : NestedTestType
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=nested
+        ]
+        Field=idx
+      ]
+      =
+      LiteralExpr [STRING] [one]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=nested
+        ]
+        Field=idx
+      ]
+      =
+      LiteralExpr [STRING] [two]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.ast
new file mode 100644
index 0000000..63392c3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.ast
@@ -0,0 +1,153 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.ast
new file mode 100644
index 0000000..6d5f9ed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.ast
@@ -0,0 +1,152 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.ast
new file mode 100644
index 0000000..9607abf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.ast
@@ -0,0 +1,173 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.ast
new file mode 100644
index 0000000..cdb65ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.ast
@@ -0,0 +1,172 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_01.ast
new file mode 100644
index 0000000..ef70cb3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_01.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_02.ast
new file mode 100644
index 0000000..9f1f805
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_02.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_03.ast
new file mode 100644
index 0000000..5addf60
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-join_03.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_01.ast
new file mode 100644
index 0000000..7ca97e3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_01.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_02.ast
new file mode 100644
index 0000000..0df6d2d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_02.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_03.ast
new file mode 100644
index 0000000..469a699
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_03.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_04.ast
new file mode 100644
index 0000000..8d0c77d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_04.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_05.ast
new file mode 100644
index 0000000..a522e08
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_05.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_06.ast
new file mode 100644
index 0000000..df80dc5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-composite-key-prefix-join_06.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl Nametmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl NameType [
+  open RecordType {
+    nested : Nametmp
+  }
+]
+DatasetDecl Names(NameType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_06.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp1 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp2 ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multiindex.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multiindex.ast
new file mode 100644
index 0000000..2619950
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multiindex.ast
@@ -0,0 +1,150 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  closed RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserTypetmp [
+  closed RecordType {
+    id : int32,
+    id-copy : int32,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    user-since-copy : datetime,
+    friend-ids : UnorderedList <int32>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageTypetmp [
+  open RecordType {
+    message-id : int32,
+    message-id-copy : int32,
+    author-id : int32,
+    in-response-to : int32?,
+    sender-location : point?,
+    message : string
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    nested : FacebookUserTypetmp
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    nested : FacebookMessageTypetmp
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[nested, id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[nested, message-id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multiindex.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [fbu-ID]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fbm-auth-ID]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=nested
+      ]
+      Field=author-id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=nested
+      ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=nested
+      ]
+      Field=message
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=message ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=message ]
+          Field=nested
+        ]
+        Field=author-id-copy
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      >=
+      LiteralExpr [LONG] [11000]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <=
+      LiteralExpr [LONG] [12000]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multipred.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multipred.ast
new file mode 100644
index 0000000..85f78c1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join-multipred.ast
@@ -0,0 +1,114 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multipred.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      =
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=misc
+      ]
+      >
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=misc
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_01.ast
new file mode 100644
index 0000000..2bfc7b9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_01.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_02.ast
new file mode 100644
index 0000000..75d15e0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_02.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_03.ast
new file mode 100644
index 0000000..13828ea
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_03.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_04.ast
new file mode 100644
index 0000000..08155b9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_04.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  open RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [arec2]
+    :
+    Variable [ Name=a2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a2 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a2 ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_05.ast
new file mode 100644
index 0000000..d890c9d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index-join/secondary-equi-join_05.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-33.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-33.ast
new file mode 100644
index 0000000..3d87a03
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-33.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-39.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-34.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-34.ast
new file mode 100644
index 0000000..e9e055d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-34.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-32.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Susan]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-35.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-35.ast
new file mode 100644
index 0000000..559946a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-35.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-33.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Isa]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-36.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-36.ast
new file mode 100644
index 0000000..12bc90c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-36.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-34.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Vanpatten]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-37.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-37.ast
new file mode 100644
index 0000000..c19e835
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-37.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-35.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    !=
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-38.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-38.ast
new file mode 100644
index 0000000..3f24f5e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-38.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-36.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-39.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-39.ast
new file mode 100644
index 0000000..c8f18e0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-39.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-37.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=lname
+    ]
+    =
+    LiteralExpr [STRING] [Kim]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-40.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-40.ast
new file mode 100644
index 0000000..96ab5cd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-40.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-38.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Young Seok]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Kim]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-41.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-41.ast
new file mode 100644
index 0000000..5c8a204
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-41.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-39.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Malaika]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-42.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-42.ast
new file mode 100644
index 0000000..0eebdd0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-42.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-40.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Alex]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zach]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-43.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-43.ast
new file mode 100644
index 0000000..c7c1070
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-43.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-41.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zubi]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-44.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-44.ast
new file mode 100644
index 0000000..bb19dc6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-44.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-42.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-45.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-45.ast
new file mode 100644
index 0000000..b54ee73
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-45.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-43.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-46.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-46.ast
new file mode 100644
index 0000000..707f74e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-46.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-44.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-47.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-47.ast
new file mode 100644
index 0000000..775f209
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-47.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-45.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-48.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-48.ast
new file mode 100644
index 0000000..14829b0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-48.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-46.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-49.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-49.ast
new file mode 100644
index 0000000..1aac06d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-49.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-47.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-50.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-50.ast
new file mode 100644
index 0000000..f2792b8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-50.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-48.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      !=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      !=
+      LiteralExpr [STRING] [Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-51.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-51.ast
new file mode 100644
index 0000000..f0b1d99
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-51.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-49.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-52.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-52.ast
new file mode 100644
index 0000000..0297232
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-52.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-50.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-53.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-53.ast
new file mode 100644
index 0000000..4a58d71
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-53.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-51.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-54.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-54.ast
new file mode 100644
index 0000000..b4e65c0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-54.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-52.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-55.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-55.ast
new file mode 100644
index 0000000..d3d837a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-55.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-53.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Sofia]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-56.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-56.ast
new file mode 100644
index 0000000..c4e1842
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-56.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-54.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Chen]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-57.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-57.ast
new file mode 100644
index 0000000..3ffdf5f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-57.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-55.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-58.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-58.ast
new file mode 100644
index 0000000..161a3dc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-58.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-56.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Neil]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-59.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-59.ast
new file mode 100644
index 0000000..5b84f63
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-59.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-57.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-60.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-60.ast
new file mode 100644
index 0000000..22ca310
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-60.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-58.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32,
+    lname : string
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=nested
+      ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-61.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-61.ast
new file mode 100644
index 0000000..78815cd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-61.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-59.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-62.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-62.ast
new file mode 100644
index 0000000..65065ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-62.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-62.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-63.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-63.ast
new file mode 100644
index 0000000..2fc1528
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/btree-index/btree-secondary-63.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-63.adm
+TypeDecl TestTypetmp [
+  open RecordType {
+    id : int32
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    nested : TestTypetmp
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[nested, id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=emp ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-contains-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-contains-panic.ast
new file mode 100644
index 0000000..26cae64
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-contains-panic.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Mu]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-contains.ast
new file mode 100644
index 0000000..61925fc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-contains.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check-panic.ast
new file mode 100644
index 0000000..d12ceed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check-panic.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check.ast
new file mode 100644
index 0000000..4555873
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-check.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-panic.ast
new file mode 100644
index 0000000..8e0250c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance-panic.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance.ast
new file mode 100644
index 0000000..e0f39a7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-edit-distance.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..44874f2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    ~=
+    LiteralExpr [STRING] [Amihay Motro]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..402b08c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    ~=
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard-check.ast
new file mode 100644
index 0000000..9b70e65
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard-check.ast
@@ -0,0 +1,68 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard.ast
new file mode 100644
index 0000000..3940247f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/ngram-jaccard.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-contains.ast
new file mode 100644
index 0000000..34ac5cb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-contains.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..17f0ea4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-fuzzyeq-jaccard.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-jaccard-check.ast
new file mode 100644
index 0000000..4ce086b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-jaccard-check.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-jaccard.ast
new file mode 100644
index 0000000..ec5d58f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-basic/word-jaccard.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
new file mode 100644
index 0000000..062e678
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
new file mode 100644
index 0000000..b3d37bd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
new file mode 100644
index 0000000..83610a0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let.ast
new file mode 100644
index 0000000..04a8d06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-let.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-substring.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-substring.ast
new file mode 100644
index 0000000..36ca9fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-substring.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
new file mode 100644
index 0000000..00611cd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-let.ast
new file mode 100644
index 0000000..2289a82
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-let.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..2c41290
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/ngram-jaccard-check-multi-let.ast
@@ -0,0 +1,70 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-let.ast
new file mode 100644
index 0000000..e2d7abe
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-let.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..37d4ee0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-complex/word-jaccard-check-multi-let.ast
@@ -0,0 +1,65 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
new file mode 100644
index 0000000..6bac05c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
@@ -0,0 +1,185 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_01.ast
new file mode 100644
index 0000000..5f185e0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_01.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_02.ast
new file mode 100644
index 0000000..9199cad
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_02.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_03.ast
new file mode 100644
index 0000000..f0f75b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_03.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_04.ast
new file mode 100644
index 0000000..de0a51f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-contains_04.ast
@@ -0,0 +1,89 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_01.ast
new file mode 100644
index 0000000..a9c2373
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_01.ast
@@ -0,0 +1,115 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_02.ast
new file mode 100644
index 0000000..6c615b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_02.ast
@@ -0,0 +1,115 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_03.ast
new file mode 100644
index 0000000..567cac1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_03.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_04.ast
new file mode 100644
index 0000000..b4e0ea6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_04.ast
@@ -0,0 +1,114 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_05.ast
new file mode 100644
index 0000000..b4e0ea6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-check_05.ast
@@ -0,0 +1,114 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-contains.ast
new file mode 100644
index 0000000..ec7ea04
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-contains.ast
@@ -0,0 +1,115 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-contains.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-inline.ast
new file mode 100644
index 0000000..6f919c6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance-inline.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-edit-distance-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aauthors]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bauthors]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_01.ast
new file mode 100644
index 0000000..aef0e68
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_01.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_02.ast
new file mode 100644
index 0000000..c612f1d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_02.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_03.ast
new file mode 100644
index 0000000..5f02579
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_03.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_04.ast
new file mode 100644
index 0000000..4c0e321
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_04.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_05.ast
new file mode 100644
index 0000000..4c0e321
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-edit-distance_05.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
new file mode 100644
index 0000000..d9997c1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast
new file mode 100644
index 0000000..0e70327
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast
new file mode 100644
index 0000000..f788eb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_04.ast
new file mode 100644
index 0000000..64bafa2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_04.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_05.ast
new file mode 100644
index 0000000..64bafa2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-edit-distance_05.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..7dc305b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,107 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..14f8baf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,107 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..f36d189
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_04.ast
new file mode 100644
index 0000000..de88875
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-fuzzyeq-jaccard_04.ast
@@ -0,0 +1,106 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_01.ast
new file mode 100644
index 0000000..680f1a4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_01.ast
@@ -0,0 +1,132 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_02.ast
new file mode 100644
index 0000000..c8c76ed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_02.ast
@@ -0,0 +1,132 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_03.ast
new file mode 100644
index 0000000..5c27747
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_03.ast
@@ -0,0 +1,117 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_04.ast
new file mode 100644
index 0000000..0aaba9d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-check_04.ast
@@ -0,0 +1,131 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-inline.ast
new file mode 100644
index 0000000..af6a5c8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard-inline.ast
@@ -0,0 +1,113 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_01.ast
new file mode 100644
index 0000000..591fe75
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_01.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_02.ast
new file mode 100644
index 0000000..3ed252f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_02.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_03.ast
new file mode 100644
index 0000000..78220a7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_03.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_04.ast
new file mode 100644
index 0000000..7362c07
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/ngram-jaccard_04.ast
@@ -0,0 +1,107 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..52b61c3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..3d5b7f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..687c075
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.ast
new file mode 100644
index 0000000..9a289ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.ast
@@ -0,0 +1,101 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check-after-btree-access.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check-after-btree-access.ast
new file mode 100644
index 0000000..6ea18ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check-after-btree-access.ast
@@ -0,0 +1,139 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t2 ]
+]
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=nested
+        ]
+        Field=message-text
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=nested
+        ]
+        Field=message-text
+      ]
+    ]
+    LiteralExpr [FLOAT] [0.6]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=nested
+        ]
+        Field=tweetid
+      ]
+      <
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=nested
+        ]
+        Field=tweetid
+      ]
+      !=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=nested
+        ]
+        Field=tweetid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_01.ast
new file mode 100644
index 0000000..b87f210
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_01.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_02.ast
new file mode 100644
index 0000000..0941add
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_02.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_03.ast
new file mode 100644
index 0000000..eee4066
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_03.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_04.ast
new file mode 100644
index 0000000..10e9f85
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-check_04.ast
@@ -0,0 +1,122 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-inline.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-inline.ast
new file mode 100644
index 0000000..67cbef2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard-inline.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join-noeqjoin_word-jaccard-inline.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [atitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [btitle]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_01.ast
new file mode 100644
index 0000000..e4bcddd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_01.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_02.ast
new file mode 100644
index 0000000..e3fd23c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_02.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_03.ast
new file mode 100644
index 0000000..1093868
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_03.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_04.ast
new file mode 100644
index 0000000..c5ffde4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/inverted-index-join/word-jaccard_04.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
new file mode 100644
index 0000000..dfb4308
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
@@ -0,0 +1,155 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
new file mode 100644
index 0000000..0b80a04
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
@@ -0,0 +1,178 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.ast
new file mode 100644
index 0000000..3698698
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordNested [
+  closed RecordType {
+    nested : MyRecord
+  }
+]
+DatasetDecl MyData1(MyRecordNested) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index-join_rtree-spatial-intersect-point.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.ast
new file mode 100644
index 0000000..e270746
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordNested [
+  closed RecordType {
+    nested : MyRecord
+  }
+]
+DatasetDecl MyData1(MyRecordNested) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.ast
new file mode 100644
index 0000000..2b58875
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordNested [
+  closed RecordType {
+    nested : MyRecord
+  }
+]
+DatasetDecl MyData(MyRecordNested) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.ast
new file mode 100644
index 0000000..f91769c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl MyRecordNestedOpen [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordOpen [
+  closed RecordType {
+    nested : MyRecordNestedOpen
+  }
+]
+DatasetDecl MyData1(MyRecordOpen) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecordOpen) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.ast
new file mode 100644
index 0000000..f91769c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+TypeDecl MyRecordNestedOpen [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordOpen [
+  closed RecordType {
+    nested : MyRecordNestedOpen
+  }
+]
+DatasetDecl MyData1(MyRecordOpen) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecordOpen) partitioned by [[nested, id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested_loj2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested_loj2.ast
new file mode 100644
index 0000000..7c06c85
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested_loj2.ast
@@ -0,0 +1,132 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+DatasetDecl LineItems(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+WriteOutputTo nc1:/tmp/nested_loj.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cust]
+    :
+    Variable [ Name=c ]
+  )
+  (
+    LiteralExpr [STRING] [orders]
+    :
+    Variable [ Name=orders ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=orders ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [order]
+        :
+        Variable [ Name=o ]
+      )
+      (
+        LiteralExpr [STRING] [items]
+        :
+        Variable [ Name=items ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+    ]
+    LetVariable [ Name=items ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=l ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItems]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_orderkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_orderkey
+            ]
+          ]
+      )
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+      ]
+  )
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested_loj3.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested_loj3.ast
new file mode 100644
index 0000000..926e14d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/nested_loj3.ast
@@ -0,0 +1,192 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItems(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl PartSupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+WriteOutputTo nc1:/tmp/nested_loj.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cust]
+    :
+    Variable [ Name=c ]
+  )
+  (
+    LiteralExpr [STRING] [orders]
+    :
+    Variable [ Name=orders ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=orders ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [order]
+        :
+        Variable [ Name=o ]
+      )
+      (
+        LiteralExpr [STRING] [items]
+        :
+        Variable [ Name=items ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+    ]
+    LetVariable [ Name=items ]
+      :=
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [item]
+            :
+            Variable [ Name=l ]
+          )
+          (
+            LiteralExpr [STRING] [part_supplier]
+            :
+            Variable [ Name=partsupp ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItems]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        LetVariable [ Name=partsupp ]
+          :=
+          (
+            SELECT ELEMENT [
+            Variable [ Name=ps ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [PartSupp]
+              ]
+              AS
+              Variable [ Name=ps ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_partkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_suppkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_suppkey
+                  ]
+                ]
+              ]
+          )
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_orderkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_orderkey
+            ]
+          ]
+      )
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+      ]
+  )
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.ast
new file mode 100644
index 0000000..4578539
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    no-idx : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=idx
+      ]
+      =
+      LiteralExpr [STRING] [one]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=idx
+      ]
+      =
+      LiteralExpr [STRING] [two]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.ast
new file mode 100644
index 0000000..9533c68
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.ast
@@ -0,0 +1,121 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.ast
new file mode 100644
index 0000000..2beceaa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.ast
@@ -0,0 +1,120 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.ast
new file mode 100644
index 0000000..7318652
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.ast
@@ -0,0 +1,135 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.ast
new file mode 100644
index 0000000..616417b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.ast
@@ -0,0 +1,134 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.ast
new file mode 100644
index 0000000..53c81c4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.ast
new file mode 100644
index 0000000..fe9fdcc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.ast
new file mode 100644
index 0000000..28f154b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.ast
new file mode 100644
index 0000000..c10a1ab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.ast
new file mode 100644
index 0000000..f5a0c73
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.ast
new file mode 100644
index 0000000..36f07af
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.ast
new file mode 100644
index 0000000..6125bf0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.ast
new file mode 100644
index 0000000..dfee5dd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_05.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.ast
new file mode 100644
index 0000000..15b8be3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl Names(Name) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_06.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp1]
+    :
+    Variable [ Name=emp1 ]
+  )
+  (
+    LiteralExpr [STRING] [emp2]
+    :
+    Variable [ Name=emp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Names]
+  ]
+  AS
+  Variable [ Name=emp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=fname
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=fname
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp1 ]
+        Field=lname
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=emp2 ]
+        Field=lname
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.ast
new file mode 100644
index 0000000..3e51567
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  closed RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int32,
+    id-copy : int32,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    user-since-copy : datetime,
+    friend-ids : UnorderedList <int32>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  open RecordType {
+    message-id : int32,
+    message-id-copy : int32,
+    author-id : int32,
+    in-response-to : int32?,
+    sender-location : point?,
+    message : string
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multiindex.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [fbu-ID]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fbm-auth-ID]
+    :
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=author-id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=message
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=message ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=author-id-copy
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      >=
+      LiteralExpr [LONG] [11000]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      <=
+      LiteralExpr [LONG] [12000]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.ast
new file mode 100644
index 0000000..6752e08
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join-multipred.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=misc
+      ]
+      >
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=misc
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.ast
new file mode 100644
index 0000000..3362470
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.ast
new file mode 100644
index 0000000..e27d9e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.ast
new file mode 100644
index 0000000..4d02d7a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.ast
new file mode 100644
index 0000000..6b634ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.ast
new file mode 100644
index 0000000..6b634ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/btree-index-join_title-secondary-equi-join_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-33.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-33.ast
new file mode 100644
index 0000000..7dcd4ad
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-33.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-31.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Roger]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-34.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-34.ast
new file mode 100644
index 0000000..b225f70
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-34.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-32.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Susan]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-35.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-35.ast
new file mode 100644
index 0000000..6a965d0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-35.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-33.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Isa]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-36.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-36.ast
new file mode 100644
index 0000000..4c1d734
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-36.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-34.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Vanpatten]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-37.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-37.ast
new file mode 100644
index 0000000..63d6979
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-37.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-35.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    !=
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-38.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-38.ast
new file mode 100644
index 0000000..63ef2cc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-38.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-36.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-39.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-39.ast
new file mode 100644
index 0000000..95e84b5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-39.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-37.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=lname
+    ]
+    =
+    LiteralExpr [STRING] [Kim]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-40.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-40.ast
new file mode 100644
index 0000000..4a6fa80
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-40.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-38.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Young Seok]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Kim]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-41.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-41.ast
new file mode 100644
index 0000000..3cf7f65
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-41.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-39.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Malaika]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-42.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-42.ast
new file mode 100644
index 0000000..1ca10d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-42.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-40.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Alex]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zach]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-43.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-43.ast
new file mode 100644
index 0000000..b6490b1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-43.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-41.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Zubi]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-44.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-44.ast
new file mode 100644
index 0000000..e3c929e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-44.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-42.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Allan]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-45.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-45.ast
new file mode 100644
index 0000000..5d1f248d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-45.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-43.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-46.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-46.ast
new file mode 100644
index 0000000..7d5f869
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-46.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-44.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-47.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-47.ast
new file mode 100644
index 0000000..0005394
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-47.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-45.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-48.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-48.ast
new file mode 100644
index 0000000..55d0226
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-48.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-46.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-49.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-49.ast
new file mode 100644
index 0000000..862fd86
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-49.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-47.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-50.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-50.ast
new file mode 100644
index 0000000..6f0be75
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-50.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-48.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      !=
+      LiteralExpr [STRING] [Michael]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      !=
+      LiteralExpr [STRING] [Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-51.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-51.ast
new file mode 100644
index 0000000..f8f11de
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-51.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-49.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-52.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-52.ast
new file mode 100644
index 0000000..f83b0ce
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-52.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-50.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-53.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-53.ast
new file mode 100644
index 0000000..533ceab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-53.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-51.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-54.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-54.ast
new file mode 100644
index 0000000..4e1882c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-54.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-52.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-55.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-55.ast
new file mode 100644
index 0000000..6589f96
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-55.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-53.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    >=
+    LiteralExpr [STRING] [Sofia]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-56.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-56.ast
new file mode 100644
index 0000000..4df6b32
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-56.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-54.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <
+    LiteralExpr [STRING] [Chen]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-57.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-57.ast
new file mode 100644
index 0000000..6b792e1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-57.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-55.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    <=
+    LiteralExpr [STRING] [Julio]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-58.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-58.ast
new file mode 100644
index 0000000..acafd98
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-58.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-56.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Neil]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-59.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-59.ast
new file mode 100644
index 0000000..30c882a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-59.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-57.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-60.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-60.ast
new file mode 100644
index 0000000..c6e4b34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-60.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-58.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=fname
+    ]
+    =
+    LiteralExpr [STRING] [Max]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-61.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-61.ast
new file mode 100644
index 0000000..277fb24
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-61.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-49.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-62.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-62.ast
new file mode 100644
index 0000000..6bef5dc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-62.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-62.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-63.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-63.ast
new file mode 100644
index 0000000..44b7ee8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/btree-index/btree-secondary-63.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-63.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Xu]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains-panic.ast
new file mode 100644
index 0000000..752ab96
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains-panic.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Mu]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains.ast
new file mode 100644
index 0000000..f0bda95
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-contains.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.ast
new file mode 100644
index 0000000..1bc655f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.ast
new file mode 100644
index 0000000..535abc4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.ast
new file mode 100644
index 0000000..14c8ca3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance.ast
new file mode 100644
index 0000000..19eb9bd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-edit-distance.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-edit-distance.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Amihay Motro]
+    ]
+    <=
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
new file mode 100644
index 0000000..5fc1e5f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    ~=
+    LiteralExpr [STRING] [Amihay Motro]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..bd0b731
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    ~=
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard-check.ast
new file mode 100644
index 0000000..a80c3b5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard-check.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard.ast
new file mode 100644
index 0000000..8ba09f2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/ngram-jaccard.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      FunctionCall test.gram-tokens@3[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-contains.ast
new file mode 100644
index 0000000..02f6e76
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-contains.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.ast
new file mode 100644
index 0000000..7f65b4a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard-check.ast
new file mode 100644
index 0000000..4e94166
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard-check.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard-check.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    Index:     FunctionCall test.similarity-jaccard-check@3[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard.ast
new file mode 100644
index 0000000..31d56de
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-basic/word-jaccard.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
new file mode 100644
index 0000000..b4ae60d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
new file mode 100644
index 0000000..117c646
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=edb ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=eda ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=edb ]
+      Index:       Variable [ Name=edb ]
+    ]
+    and
+    IndexAccessor [
+      Variable [ Name=eda ]
+      Index:       Variable [ Name=eda ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
new file mode 100644
index 0000000..0dbfd47
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.ast
new file mode 100644
index 0000000..6e36688
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.ast
new file mode 100644
index 0000000..326ecfa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.ast
@@ -0,0 +1,65 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      FunctionCall test.substring@3[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [0]
+        LiteralExpr [LONG] [8]
+      ]
+      LiteralExpr [STRING] [datbase]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
new file mode 100644
index 0000000..146b5fb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.ast
new file mode 100644
index 0000000..50c1eee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..a021ee6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-let.ast
new file mode 100644
index 0000000..572a3b5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-let.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-let.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.ast
new file mode 100644
index 0000000..4e81a84
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-complex_word-jaccard-check-multi-let.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Paper]
+    :
+    Variable [ Name=paper_tokens ]
+  )
+  (
+    LiteralExpr [STRING] [Query]
+    :
+    Variable [ Name=query_tokens ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
new file mode 100644
index 0000000..7cb7620
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.ast
@@ -0,0 +1,147 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_01.ast
new file mode 100644
index 0000000..5f185e0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_01.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_02.ast
new file mode 100644
index 0000000..749ac15
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_02.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_03.ast
new file mode 100644
index 0000000..f0f75b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_03.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_04.ast
new file mode 100644
index 0000000..de0a51f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-contains_04.ast
@@ -0,0 +1,89 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-contains-04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [title1]
+    :
+    FieldAccessor [
+      Variable [ Name=o1 ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=title
+      ]
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_01.ast
new file mode 100644
index 0000000..e2be001
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_01.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_02.ast
new file mode 100644
index 0000000..ee772de
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_02.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_03.ast
new file mode 100644
index 0000000..2625826
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_03.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_04.ast
new file mode 100644
index 0000000..c03fc57
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_04.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_05.ast
new file mode 100644
index 0000000..c03fc57
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_05.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-check@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_inline_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_inline_03.ast
new file mode 100644
index 0000000..4f9f6f5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-check_inline_03.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    IndexAccessor [
+      Variable [ Name=ed ]
+      Index:       Variable [ Name=ed ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=ed ]
+      Index:       Variable [ Name=ed ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-contains.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-contains.ast
new file mode 100644
index 0000000..1078ccd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance-contains.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance-contains.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+      Index:       FunctionCall test.edit-distance-contains@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_01.ast
new file mode 100644
index 0000000..924c2ba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_01.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_02.ast
new file mode 100644
index 0000000..e6b16a4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_02.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_03.ast
new file mode 100644
index 0000000..5cf795e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_03.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_04.ast
new file mode 100644
index 0000000..e29c169
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_04.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_05.ast
new file mode 100644
index 0000000..e29c169
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_05.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=authors
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=authors
+        ]
+      ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_inline_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_inline_03.ast
new file mode 100644
index 0000000..1ffecec
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-edit-distance_inline_03.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-edit-distance_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
new file mode 100644
index 0000000..a67bb4f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_01.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast
new file mode 100644
index 0000000..5228f37
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_02.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast
new file mode 100644
index 0000000..9f1edbf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_03.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_03.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_04.ast
new file mode 100644
index 0000000..d105d66
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_04.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_05.ast
new file mode 100644
index 0000000..d105d66
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-edit-distance_05.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-edit-distance_01.adm
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=authors
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=authors
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..2d6fd8c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..f54a688
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_02.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..6afbdd9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_03.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_04.ast
new file mode 100644
index 0000000..3e1f2d1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-fuzzyeq-jaccard_04.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+      ~=
+      FunctionCall test.gram-tokens@3[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+        LiteralExpr [LONG] [3]
+        LiteralExpr [FALSE]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_01.ast
new file mode 100644
index 0000000..36048d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_01.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_02.ast
new file mode 100644
index 0000000..6b235f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_02.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_03.ast
new file mode 100644
index 0000000..da9f690
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_03.ast
@@ -0,0 +1,94 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_04.ast
new file mode 100644
index 0000000..3410831
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_04.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_inline_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_inline_03.ast
new file mode 100644
index 0000000..b17c189
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard-check_inline_03.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_01.ast
new file mode 100644
index 0000000..c9cae12
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_01.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_02.ast
new file mode 100644
index 0000000..da9c748
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_02.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_03.ast
new file mode 100644
index 0000000..6a20190
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_03.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_04.ast
new file mode 100644
index 0000000..86c04c2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_04.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_inline_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_inline_03.ast
new file mode 100644
index 0000000..95454f5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/ngram-jaccard_inline_03.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Set import-private-functions=true
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_ngram-jaccard_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_01.ast
new file mode 100644
index 0000000..575738b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_01.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_02.ast
new file mode 100644
index 0000000..bc2ab3e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_02.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_02.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_03.ast
new file mode 100644
index 0000000..6b18e22
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_03.ast
@@ -0,0 +1,70 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_03.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.ast
new file mode 100644
index 0000000..c352aed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-fuzzyeq-jaccard_01.adm
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check-after-btree-access.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check-after-btree-access.ast
new file mode 100644
index 0000000..4d96b4c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check-after-btree-access.ast
@@ -0,0 +1,113 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check-after-btree-access.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2]
+    :
+    FieldAccessor [
+      Variable [ Name=t2 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t2 ]
+]
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=message-text
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=message-text
+      ]
+    ]
+    LiteralExpr [FLOAT] [0.6]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=tweetid
+      ]
+      <
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=tweetid
+      ]
+      !=
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=tweetid
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_01.ast
new file mode 100644
index 0000000..9312f4f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_01.ast
@@ -0,0 +1,95 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_02.ast
new file mode 100644
index 0000000..c522135
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_02.ast
@@ -0,0 +1,95 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_03.ast
new file mode 100644
index 0000000..3b51a56
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_03.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_04.ast
new file mode 100644
index 0000000..ea0d477
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_04.ast
@@ -0,0 +1,94 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+      Index:       FunctionCall test.similarity-jaccard-check@3[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_inline_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_inline_03.ast
new file mode 100644
index 0000000..8c9a4b7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard-check_inline_03.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard-check_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    IndexAccessor [
+      Variable [ Name=jacc ]
+      Index:       Variable [ Name=jacc ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_01.ast
new file mode 100644
index 0000000..d506e1bc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_01.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_02.ast
new file mode 100644
index 0000000..4071847
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_02.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_03.ast
new file mode 100644
index 0000000..8ea189a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_03.ast
@@ -0,0 +1,71 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_04.ast
new file mode 100644
index 0000000..615ec68
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_04.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int32,
+    csxid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_inline_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_inline_03.ast
new file mode 100644
index 0000000..42f995e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/inverted-index-join/word-jaccard_inline_03.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-join_word-jaccard_04.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
new file mode 100644
index 0000000..b0f9288
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
@@ -0,0 +1,126 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
new file mode 100644
index 0000000..d37268a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_01.ast
new file mode 100644
index 0000000..fc94123
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_01.ast
@@ -0,0 +1,65 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData1(MyRecordOpen) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index-join_rtree-spatial-intersect-point.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_02.ast
new file mode 100644
index 0000000..13a1358
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_02.ast
@@ -0,0 +1,65 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData1(MyRecord) partitioned by [[id]]
+DatasetDecl MyData2(MyRecordOpen) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_03.ast
new file mode 100644
index 0000000..d890e8a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_03.ast
@@ -0,0 +1,52 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_04.ast
new file mode 100644
index 0000000..038fc0a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_04.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData1(MyRecord) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_05.ast
new file mode 100644
index 0000000..038fc0a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/open-index-enforced/rtree-index-join/spatial-intersect-point_05.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int32,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData1(MyRecord) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orderby-desc-using-gby.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orderby-desc-using-gby.ast
new file mode 100644
index 0000000..e2d5014
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orderby-desc-using-gby.ast
@@ -0,0 +1,62 @@
+DataverseUse gby-using-orderby-desc
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:rttest/gby-using-orderby-desc.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    Variable [ Name=name ]
+  )
+  (
+    LiteralExpr [STRING] [age]
+    :
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [age]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Groupby
+  Variable [ Name=name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=name
+  ]
+  With
+  Variable [ Name=c ]
+
+Orderby
+  Variable [ Name=name ]
+  DESC
+  Variable [ Name=age ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-aggreg.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-aggreg.ast
new file mode 100644
index 0000000..643a8b0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-aggreg.ast
@@ -0,0 +1,82 @@
+DataverseUse orders-aggreg
+TypeDecl OrderType [
+  closed RecordType {
+    oid : int32,
+    cid : int32,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
+WriteOutputTo nc1:/tmp/orders-aggreg.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cid]
+    :
+    Variable [ Name=cid ]
+  )
+  (
+    LiteralExpr [STRING] [ordpercust]
+    :
+    FunctionCall orders-aggreg.count@1[
+      Variable [ Name=o ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [totalcust]
+    :
+    FunctionCall orders-aggreg.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=total
+        ]
+        ]
+        FROM [          Variable [ Name=o ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [avgcust]
+    :
+    FunctionCall orders-aggreg.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=total
+        ]
+        ]
+        FROM [          Variable [ Name=o ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Groupby
+  Variable [ Name=cid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=cid
+  ]
+  With
+  Variable [ Name=o ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-composite-index-search.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-composite-index-search.ast
new file mode 100644
index 0000000..ca0be74
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-composite-index-search.ast
@@ -0,0 +1,71 @@
+DataverseUse index_search
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderstatus
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderstatus
+      ]
+      =
+      LiteralExpr [STRING] [P]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive-open_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive-open_01.ast
new file mode 100644
index 0000000..66d6a4b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive-open_01.ast
@@ -0,0 +1,70 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search-conjunctive.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive-open_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive-open_02.ast
new file mode 100644
index 0000000..860b0fd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive-open_02.ast
@@ -0,0 +1,78 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search-conjunctive.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_totalprice]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_totalprice
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive_01.ast
new file mode 100644
index 0000000..9e4beb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive_01.ast
@@ -0,0 +1,70 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search-conjunctive.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive_02.ast
new file mode 100644
index 0000000..136f1f8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-conjunctive_02.ast
@@ -0,0 +1,78 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search-conjunctive.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_totalprice]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_totalprice
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-open.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-open.ast
new file mode 100644
index 0000000..7eeb2b7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search-open.ast
@@ -0,0 +1,52 @@
+DataverseUse index_search
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search.ast
new file mode 100644
index 0000000..31fe195
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/orders-index-search.ast
@@ -0,0 +1,52 @@
+DataverseUse index_search
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/index_search.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/prim-idx-search-open.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/prim-idx-search-open.ast
new file mode 100644
index 0000000..4217fa0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/prim-idx-search-open.ast
@@ -0,0 +1,52 @@
+DataverseUse prim_index_search
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/prim_index_search.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+    =
+    LiteralExpr [LONG] [34]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/prim-idx-search.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/prim-idx-search.ast
new file mode 100644
index 0000000..6574c68
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/prim-idx-search.ast
@@ -0,0 +1,52 @@
+DataverseUse prim_index_search
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/prim_index_search.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+    =
+    LiteralExpr [LONG] [34]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/pull_select_above_eq_join.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/pull_select_above_eq_join.ast
new file mode 100644
index 0000000..2f71b8b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/pull_select_above_eq_join.ast
@@ -0,0 +1,81 @@
+DataverseUse pull-select-above-eq-join
+TypeDecl UserType [
+  open RecordType {
+    uid : int32,
+    name : string,
+    city : string,
+    lottery_numbers : UnorderedList <int32>
+
+  }
+]
+TypeDecl VisitorType [
+  open RecordType {
+    vid : int32,
+    name : string,
+    city : string,
+    lottery_numbers : UnorderedList <int32>
+
+  }
+]
+DatasetDecl Users(UserType) partitioned by [[uid]]
+DatasetDecl Visitors(VisitorType) partitioned by [[vid]]
+WriteOutputTo nc1:/tmp/pull-select-above-eq-join.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [uid]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=uid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [vid]
+    :
+    FieldAccessor [
+      Variable [ Name=visitor ]
+      Field=vid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Users]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Visitors]
+  ]
+  AS
+  Variable [ Name=visitor ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=name
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=visitor ]
+        Field=name
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=city
+      ]
+      !=
+      FieldAccessor [
+        Variable [ Name=visitor ]
+        Field=city
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/push-project-through-group.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/push-project-through-group.ast
new file mode 100644
index 0000000..45841bd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/push-project-through-group.ast
@@ -0,0 +1,64 @@
+DataverseUse fuzzyjoin_080
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/fuzzyjoin_080.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [matches]
+    :
+    Variable [ Name=matches ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=matches ]
+  :=
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paper ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=authors
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=authors
+        ]
+      ]
+  )
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/push_limit.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/push_limit.ast
new file mode 100644
index 0000000..914f997
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/push_limit.ast
@@ -0,0 +1,63 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+WriteOutputTo nc1:/tmp/push_limit.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [price]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_totalprice
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderdate
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_totalprice
+    ]
+    >
+    LiteralExpr [LONG] [100]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [10]
+  Offset
+    LiteralExpr [LONG] [5]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q01_pricing_summary_report_nt.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q01_pricing_summary_report_nt.ast
new file mode 100644
index 0000000..9ed8f0e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q01_pricing_summary_report_nt.ast
@@ -0,0 +1,239 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+WriteOutputTo nc1:rttest/tpch_q1_pricing_summary_report_nt.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [sum_qty]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_base_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_charge]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            +
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_tax
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_qty]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_price]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_disc]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q03_shipping_priority.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q03_shipping_priority.ast
new file mode 100644
index 0000000..81491c0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q03_shipping_priority.ast
@@ -0,0 +1,209 @@
+DataverseUse q3_shipping_priority
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+DatasetDecl LineItems(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+WriteOutputTo nc1:/tmp/q3_shipping_priority.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_orderkey]
+    :
+    Variable [ Name=l_orderkey ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    Variable [ Name=o_orderdate ]
+  )
+  (
+    LiteralExpr [STRING] [o_shippriority]
+    :
+    Variable [ Name=o_shippriority ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItems]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_mktsegment
+        ]
+        =
+        LiteralExpr [STRING] [BUILDING]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+        <
+        LiteralExpr [STRING] [1995-03-15]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipdate
+        ]
+        >
+        LiteralExpr [STRING] [1995-03-15]
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=l_orderkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_orderkey
+  ]
+  Variable [ Name=o_orderdate ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderdate
+  ]
+  Variable [ Name=o_shippriority ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_shippriority
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall q3_shipping_priority.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+  Variable [ Name=o_orderdate ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [10]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q05_local_supplier_volume.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q05_local_supplier_volume.ast
new file mode 100644
index 0000000..0e1f7ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q05_local_supplier_volume.ast
@@ -0,0 +1,433 @@
+DataverseUse q5_local_supplier
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl LineItems(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customers(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl Suppliers(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Nations(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Regions(RegionType) partitioned by [[r_regionkey]]
+WriteOutputTo nc1:/tmp/q5_local_supplier.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=s_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItems]
+          ]
+          AS
+          Variable [ Name=l ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=n1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_nationkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Suppliers]
+              ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Nations]
+                  ]
+                  AS
+                  Variable [ Name=n ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Regions]
+                  ]
+                  AS
+                  Variable [ Name=r ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=n ]
+                        Field=n_regionkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_regionkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_name
+                      ]
+                      =
+                      LiteralExpr [STRING] [ASIA]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=n1 ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=n1 ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=s1 ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l1 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l1 ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderdate
+          ]
+          >=
+          LiteralExpr [STRING] [1994-01-01]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderdate
+          ]
+          <
+          LiteralExpr [STRING] [1995-01-01]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=o1 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=s_nationkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_custkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=o_custkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=n_name
+  ]
+  With
+  Variable [ Name=o1 ]
+  Variable [ Name=c ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall q5_local_supplier.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=o1 ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q08_group_by.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q08_group_by.ast
new file mode 100644
index 0000000..0e9337f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q08_group_by.ast
@@ -0,0 +1,442 @@
+DataverseUse q08_group_by
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    FieldAccessor [
+      Variable [ Name=lnrcop ]
+      Field=o_orderdate
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_discount]
+    :
+    FieldAccessor [
+      Variable [ Name=lnrcop ]
+      Field=l_discount
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_extendedprice]
+    :
+    FieldAccessor [
+      Variable [ Name=lnrcop ]
+      Field=l_extendedprice
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_suppkey]
+    :
+    FieldAccessor [
+      Variable [ Name=lnrcop ]
+      Field=l_suppkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_nationkey]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_nationkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Supplier]
+  ]
+  AS
+  Variable [ Name=s ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [o_orderdate]
+        :
+        FieldAccessor [
+          Variable [ Name=lnrco ]
+          Field=o_orderdate
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=lnrco ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=lnrco ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=lnrco ]
+          Field=l_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [o_orderdate]
+            :
+            FieldAccessor [
+              Variable [ Name=nrco ]
+              Field=o_orderdate
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [o_orderdate]
+                :
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+              )
+              (
+                LiteralExpr [STRING] [o_orderkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Orders]
+              ]
+              AS
+              Variable [ Name=o ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [c_custkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=c ]
+                      Field=c_custkey
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Customer]
+                  ]
+                  AS
+                  Variable [ Name=c ]
+,
+                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [n_nationkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=n1 ]
+                          Field=n_nationkey
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Nation]
+                      ]
+                      AS
+                      Variable [ Name=n1 ]
+,
+                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Region]
+                      ]
+                      AS
+                      Variable [ Name=r1 ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        OperatorExpr [
+                          FieldAccessor [
+                            Variable [ Name=n1 ]
+                            Field=n_regionkey
+                          ]
+                          =
+                          FieldAccessor [
+                            Variable [ Name=r1 ]
+                            Field=r_regionkey
+                          ]
+                        ]
+                        and
+                        OperatorExpr [
+                          FieldAccessor [
+                            Variable [ Name=r1 ]
+                            Field=r_name
+                          ]
+                          =
+                          LiteralExpr [STRING] [AMERICA]
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=nr ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=c ]
+                      Field=c_nationkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=nr ]
+                      Field=n_nationkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=nrc ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=nrc ]
+                  Field=c_custkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=nrco ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_orderkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=nrco ]
+                Field=o_orderkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=nrco ]
+                Field=o_orderdate
+              ]
+              >=
+              LiteralExpr [STRING] [1995-01-01]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=nrco ]
+                Field=o_orderdate
+              ]
+              <=
+              LiteralExpr [STRING] [1996-12-31]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=lnrco ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Part]
+      ]
+      AS
+      Variable [ Name=p ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=lnrco ]
+            Field=l_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_type
+          ]
+          =
+          LiteralExpr [STRING] [ECONOMY ANODIZED STEEL]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=lnrcop ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_suppkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=lnrcop ]
+      Field=l_suppkey
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q09_group_by.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q09_group_by.ast
new file mode 100644
index 0000000..8f0e8b8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q09_group_by.ast
@@ -0,0 +1,412 @@
+DataverseUse q09_group_by
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_extendedprice]
+    :
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=l_extendedprice
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_discount]
+    :
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=l_discount
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_quantity]
+    :
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=l_quantity
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=l_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ps_supplycost]
+    :
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=ps_supplycost
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Part]
+  ]
+  AS
+  Variable [ Name=p ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_quantity]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_quantity
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_partkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_partkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_orderkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [ps_supplycost]
+        :
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_supplycost
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Partsupp]
+      ]
+      AS
+      Variable [ Name=ps ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_quantity]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_quantity
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=n_name
+            ]
+          )
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=n ]
+                  Field=n_name
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Supplier]
+              ]
+              AS
+              Variable [ Name=s ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Nation]
+              ]
+              AS
+              Variable [ Name=n ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=n ]
+                  Field=n_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=s1 ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l1 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=l1 ]
+            Field=l_suppkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=l1 ]
+            Field=l_partkey
+          ]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=l2 ]
+]
+Where
+  OperatorExpr [
+    FunctionCall q09_group_by.contains@2[
+      FieldAccessor [
+        Variable [ Name=p ]
+        Field=p_name
+      ]
+      LiteralExpr [STRING] [green]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=p ]
+        Field=p_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=l2 ]
+        Field=l_partkey
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q1.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q1.ast
new file mode 100644
index 0000000..4c5e744
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q1.ast
@@ -0,0 +1,63 @@
+DataverseUse events
+TypeDecl AddressType [
+  closed RecordType {
+    street : string,
+    city : string,
+    zip : string,
+    latlong : point
+  }
+]
+TypeDecl UserType [
+  open RecordType {
+    name : string,
+    email : string,
+    interests : UnorderedList <string>
+,
+    address : AddressType,
+    member_of : UnorderedList <          open RecordType {
+            sig_name : string,
+            chapter_name : string,
+            member_since : date
+          }
+>
+
+  }
+]
+DatasetDecl User(UserType) partitioned by [[name]]
+WriteOutputTo nc1:/tmp/q1.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=i ]
+        =
+        LiteralExpr [STRING] [movies]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q2.ast
new file mode 100644
index 0000000..a7bc644
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/q2.ast
@@ -0,0 +1,145 @@
+DataverseUse events
+TypeDecl AddressType [
+  closed RecordType {
+    street : string,
+    city : string,
+    zip : string
+  }
+]
+TypeDecl EventType [
+  closed RecordType {
+    name : string,
+    location : AddressType?,
+    organizers : UnorderedList <          open RecordType {
+            name : string,
+            role : string
+          }
+>
+,
+    sponsoring_sigs : OrderedList [          open RecordType {
+            sig_name : string,
+            chapter_name : string
+          }
+]
+,
+    interest_keywords : UnorderedList <string>
+,
+    price : double?,
+    start_time : datetime,
+    end_time : datetime
+  }
+]
+DatasetDecl Event(EventType) partitioned by [[name]]
+WriteOutputTo nc1:/tmp/q2.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sig_name]
+    :
+    Variable [ Name=sig_name ]
+  )
+  (
+    LiteralExpr [STRING] [total_count]
+    :
+    Variable [ Name=sig_sponsorship_count ]
+  )
+  (
+    LiteralExpr [STRING] [chapter_breakdown]
+    :
+    Variable [ Name=by_chapter ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Event]
+  ]
+  AS
+  Variable [ Name=event ]
+,
+  FieldAccessor [
+    Variable [ Name=event ]
+    Field=sponsoring_sigs
+  ]
+  AS
+  Variable [ Name=sponsor ]
+]
+LetVariable [ Name=es ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [event]
+      :
+      Variable [ Name=event ]
+    )
+    (
+      LiteralExpr [STRING] [sponsor]
+      :
+      Variable [ Name=sponsor ]
+    )
+  ]
+Groupby
+  Variable [ Name=sig_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=sponsor ]
+    Field=sig_name
+  ]
+  With
+  Variable [ Name=es ]
+  Variable [ Name=sponsor ]
+  Variable [ Name=event ]
+
+LetVariable [ Name=sig_sponsorship_count ]
+  :=
+  FunctionCall events.count@1[
+    Variable [ Name=es ]
+  ]
+LetVariable [ Name=by_chapter ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [chapter_name]
+        :
+        Variable [ Name=chapter_name ]
+      )
+      (
+        LiteralExpr [STRING] [escount]
+        :
+        FunctionCall events.count@1[
+          Variable [ Name=e ]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=es ]
+      AS
+      Variable [ Name=e ]
+    ]
+    Groupby
+      Variable [ Name=chapter_name ]
+      :=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=e ]
+          Field=sponsor
+        ]
+        Field=chapter_name
+      ]
+      With
+      Variable [ Name=e ]
+      Variable [ Name=by_chapter ]
+      Variable [ Name=sig_sponsorship_count ]
+      Variable [ Name=es ]
+      Variable [ Name=sponsor ]
+      Variable [ Name=event ]
+
+  )
+Orderby
+  Variable [ Name=sig_sponsorship_count ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [5]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue550.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue550.ast
new file mode 100644
index 0000000..416cf4e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue550.ast
@@ -0,0 +1,186 @@
+Query:
+LetVariable [ Name=sample ]
+  :=
+  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [1]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:00:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [2]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:01:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e2]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [3]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [3c4d]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:02:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [4]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [3c4d]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:03:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e3]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [5]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:04:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [6]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:05:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e4]
+      )
+    ]
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [u]
+    :
+    Variable [ Name=u ]
+  )
+  (
+    LiteralExpr [STRING] [recs]
+    :
+    (
+      SELECT ELEMENT [
+      Variable [ Name=srec ]
+      ]
+      FROM [        Variable [ Name=s ]
+        AS
+        Variable [ Name=srec ]
+      ]
+    )
+  )
+]
+]
+FROM [  Variable [ Name=sample ]
+  AS
+  Variable [ Name=s ]
+]
+Groupby
+  Variable [ Name=u ]
+  :=
+  FieldAccessor [
+    Variable [ Name=s ]
+    Field=uid
+  ]
+  With
+  Variable [ Name=s ]
+  Variable [ Name=sample ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue562.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue562.ast
new file mode 100644
index 0000000..7f8f2d3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue562.ast
@@ -0,0 +1,304 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+FunctionDecl q22_customer_tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [cntrycode]
+        :
+        Variable [ Name=phone_substr ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Customer ]
+      AS
+      Variable [ Name=c ]
+    ]
+    LetVariable [ Name=phone_substr ]
+      :=
+      FunctionCall tpch.substring@3[
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_phone
+        ]
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [13]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [31]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [23]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [29]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [30]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [18]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [17]
+        ]
+      ]
+  )
+}
+
+Query:
+LetVariable [ Name=avg ]
+  :=
+  FunctionCall tpch.avg@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_acctbal
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=c ]
+      ]
+      LetVariable [ Name=phone_substr ]
+        :=
+        FunctionCall tpch.substring@3[
+          FieldAccessor [
+            Variable [ Name=c ]
+            Field=c_phone
+          ]
+          LiteralExpr [LONG] [1]
+          LiteralExpr [LONG] [2]
+        ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_acctbal
+            ]
+            >
+            LiteralExpr [DOUBLE] [0.0]
+          ]
+          and
+          OperatorExpr [
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [13]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [31]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [23]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [29]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [30]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [18]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [17]
+            ]
+          ]
+        ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cntrycode]
+    :
+    Variable [ Name=cntrycode ]
+  )
+  (
+    LiteralExpr [STRING] [numcust]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=ct ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [totacctbal]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=c_acctbal
+        ]
+        ]
+        FROM [          Variable [ Name=ct ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall tpch.q22_customer_tmp@0[
+  ]
+  AS
+  Variable [ Name=ct ]
+]
+Where
+  OperatorExpr [
+    FunctionCall tpch.count@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=o ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=ct ]
+              Field=c_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_custkey
+            ]
+          ]
+      )
+    ]
+    =
+    LiteralExpr [LONG] [0]
+  ]
+Groupby
+  Variable [ Name=cntrycode ]
+  :=
+  FieldAccessor [
+    Variable [ Name=ct ]
+    Field=cntrycode
+  ]
+  With
+  Variable [ Name=ct ]
+  Variable [ Name=avg ]
+
+Orderby
+  Variable [ Name=cntrycode ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue601.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue601.ast
new file mode 100644
index 0000000..fef8a60
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue601.ast
@@ -0,0 +1,55 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_linenumber]
+    :
+    Variable [ Name=l_linenumber ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Groupby
+  Variable [ Name=l_linenumber ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linenumber
+  ]
+  With
+  Variable [ Name=l ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue697.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue697.ast
new file mode 100644
index 0000000..1409681
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue697.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    key1 : int32,
+    value : int32
+  }
+]
+DatasetDecl test(TestType) partitioned by [[key1]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [gid]
+    :
+    Variable [ Name=aid ]
+  )
+  (
+    LiteralExpr [STRING] [avg]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=j ]
+          Field=value
+        ]
+        ]
+        FROM [          Variable [ Name=i ]
+          AS
+          Variable [ Name=j ]
+        ]
+        Where
+          FunctionCall test.not@1[
+            FunctionCall test.is-null@1[
+              FieldAccessor [
+                Variable [ Name=j ]
+                Field=value
+              ]
+            ]
+          ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Groupby
+  Variable [ Name=aid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=key1
+  ]
+  With
+  Variable [ Name=i ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue785.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue785.ast
new file mode 100644
index 0000000..5b5cb9a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue785.ast
@@ -0,0 +1,272 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
+Query:
+LetVariable [ Name=t ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [n_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_name
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=nation ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [SelectedNation]
+      ]
+      AS
+      Variable [ Name=sn ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=sn ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+LetVariable [ Name=X ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation_key]
+        :
+        Variable [ Name=nation_key ]
+      )
+      (
+        LiteralExpr [STRING] [order_date]
+        :
+        Variable [ Name=orderdate ]
+      )
+      (
+        LiteralExpr [STRING] [sum_price]
+        :
+        Variable [ Name=sum ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=t ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Customer]
+      ]
+      AS
+      Variable [ Name=customer ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=orders ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=orders ]
+            Field=o_custkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_custkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_nationkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=n ]
+            Field=n_nationkey
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=orderdate ]
+      :=
+      FieldAccessor [
+        Variable [ Name=orders ]
+        Field=o_orderdate
+      ]
+      Variable [ Name=nation_key ]
+      :=
+      FieldAccessor [
+        Variable [ Name=n ]
+        Field=n_nationkey
+      ]
+      With
+      Variable [ Name=orders ]
+      Variable [ Name=n ]
+      Variable [ Name=customer ]
+      Variable [ Name=X ]
+      Variable [ Name=t ]
+
+    LetVariable [ Name=sum ]
+      :=
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_totalprice
+          ]
+          ]
+          FROM [            Variable [ Name=orders ]
+            AS
+            Variable [ Name=o ]
+          ]
+        )
+      ]
+  )
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    Variable [ Name=nation_key ]
+  )
+  (
+    LiteralExpr [STRING] [sum_price]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [orderdate]
+          :
+          FieldAccessor [
+            Variable [ Name=y ]
+            Field=order_date
+          ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          FieldAccessor [
+            Variable [ Name=y ]
+            Field=sum_price
+          ]
+        )
+      ]
+      ]
+      FROM [        Variable [ Name=x ]
+        AS
+        Variable [ Name=y ]
+      ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=y ]
+          Field=sum_price
+        ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  Variable [ Name=X ]
+  AS
+  Variable [ Name=x ]
+]
+Groupby
+  Variable [ Name=nation_key ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=nation_key
+  ]
+  With
+  Variable [ Name=x ]
+  Variable [ Name=X ]
+  Variable [ Name=t ]
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue810-2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue810-2.ast
new file mode 100644
index 0000000..1726c87
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue810-2.ast
@@ -0,0 +1,204 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [count_cheaps]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=cheaps ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [avg_expensive_discounts]
+    :
+    FunctionCall tpch.avg@1[
+      Variable [ Name=expensives ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_prices]
+    :
+    FunctionCall tpch.sum@1[
+      Variable [ Name=disc_prices ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [total_charges]
+    :
+    FunctionCall tpch.sum@1[
+      Variable [ Name=charges ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+LetVariable [ Name=expensives ]
+  :=
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=l_discount
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        <=
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=cheaps ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        >
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=charges ]
+  :=
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        +
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_tax
+        ]
+      ]
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+  )
+LetVariable [ Name=disc_prices ]
+  :=
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+      ]
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+  )
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue810.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue810.ast
new file mode 100644
index 0000000..3be4f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue810.ast
@@ -0,0 +1,128 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [count_cheaps]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=cheap ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_expensives]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=expensive ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+LetVariable [ Name=cheap ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=m ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=m ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=m ]
+          Field=l_discount
+        ]
+        >
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=expensive ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=a ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=a ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=l_discount
+        ]
+        <=
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue827-2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue827-2.ast
new file mode 100644
index 0000000..56a8784
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query-issue827-2.ast
@@ -0,0 +1,231 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sum_qty_partial]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_shipdate
+            ]
+            <=
+            LiteralExpr [STRING] [1998-09-02]
+          ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_base_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_charge]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            +
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_tax
+            ]
+          ]
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_qty]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_shipdate
+            ]
+            <=
+            LiteralExpr [STRING] [1998-09-02]
+          ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_price]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_disc]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=l ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query_issue849-2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query_issue849-2.ast
new file mode 100644
index 0000000..7a7b3f2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query_issue849-2.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+TypeDecl sType [
+  closed RecordType {
+    b : int32
+  }
+]
+DatasetDecl s(sType) partitioned by [[b]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [x]
+    :
+    Variable [ Name=x ]
+  )
+  (
+    LiteralExpr [STRING] [y]
+    :
+    Variable [ Name=y ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [s]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=z ]
+      Field=c
+    ]
+    ]
+    FROM [      UnorderedListConstructor [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [a]
+            :
+            LiteralExpr [LONG] [1]
+          )
+          (
+            LiteralExpr [STRING] [c]
+            :
+            LiteralExpr [LONG] [1]
+          )
+        ]
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [a]
+            :
+            LiteralExpr [LONG] [2]
+          )
+          (
+            LiteralExpr [STRING] [c]
+            :
+            LiteralExpr [LONG] [2]
+          )
+        ]
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [a]
+            :
+            LiteralExpr [LONG] [1]
+          )
+          (
+            LiteralExpr [STRING] [c]
+            :
+            LiteralExpr [NULL]
+          )
+        ]
+      ]
+      AS
+      Variable [ Name=z ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=b
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=z ]
+          Field=a
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query_issue849.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query_issue849.ast
new file mode 100644
index 0000000..98b006e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/query_issue849.ast
@@ -0,0 +1,70 @@
+DataverseUse test
+TypeDecl sType [
+  closed RecordType {
+    b : int32
+  }
+]
+DatasetDecl s(sType) partitioned by [[b]]
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [x]
+    :
+    Variable [ Name=x ]
+  )
+  (
+    LiteralExpr [STRING] [y]
+    :
+    Variable [ Name=y ]
+  )
+]
+]
+FROM [  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [a]
+        :
+        LiteralExpr [LONG] [1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [a]
+        :
+        LiteralExpr [LONG] [2]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=z ]
+      Field=b
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [s]
+      ]
+      AS
+      Variable [ Name=z ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=a
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=z ]
+          Field=b
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-numeric-desc.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-numeric-desc.ast
new file mode 100644
index 0000000..576eeb7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-numeric-desc.ast
@@ -0,0 +1,29 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=friends_count
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-numeric.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-numeric.ast
new file mode 100644
index 0000000..ec49be3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-numeric.ast
@@ -0,0 +1,29 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=friends_count
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-string-desc.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-string-desc.ast
new file mode 100644
index 0000000..aefabe9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-string-desc.ast
@@ -0,0 +1,29 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=screen-name
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-string.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-string.ast
new file mode 100644
index 0000000..28b636d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/range-connector/sort-hint-on-closed-string.ast
@@ -0,0 +1,29 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=screen-name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/record_access.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/record_access.ast
new file mode 100644
index 0000000..013ea15
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/record_access.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+WriteOutputTo nc1:/tmp/rec_access.adm
+Query:
+FieldAccessor [
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [a]
+      :
+      LiteralExpr [LONG] [2]
+    )
+  ]
+  Field=a
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/issue730.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/issue730.ast
new file mode 100644
index 0000000..e98418d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/issue730.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen_name : string,
+    lang : string,
+    friends_count : int32,
+    statuses_count : int32,
+    name : string,
+    followers_count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender_location : point?,
+    send_time : datetime,
+    referred_topics : UnorderedList <string>
+,
+    message_text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_issue730.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=tweetid
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender_location
+          ]
+          Variable [ Name=n ]
+        ]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender_location
+    ]
+    LiteralExpr [DOUBLE] [5.0]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=send_time
+      ]
+      >=
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-06-18T14:10:17]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=send_time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-06-18T15:10:17]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
new file mode 100644
index 0000000..1c45852
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_01.ast
@@ -0,0 +1,127 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_01.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
new file mode 100644
index 0000000..628cc16
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/leftouterjoin-probe-pidx-with-join-rtree-sidx_02.ast
@@ -0,0 +1,141 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int32,
+    statuses-count : int32,
+    name : string,
+    followers-count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int32,
+    countB : int32
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/rtree-index-join_leftouterjoin-probe-pidx-with-join-rtree-sidx_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/query-issue838.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/query-issue838.ast
new file mode 100644
index 0000000..de3f414
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/query-issue838.ast
@@ -0,0 +1,88 @@
+DataverseUse twitter
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    sender-location : point,
+    text : string
+  }
+]
+TypeDecl TweetHistorySubscription [
+  open RecordType {
+    subscription-id : int32,
+    location : point
+  }
+]
+DatasetDecl TweetHistorySubscriptions(TweetHistorySubscription) partitioned by [[subscription-id]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+WriteOutputTo nc1:rttest/query-issue838.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [subscription-id]
+    :
+    FieldAccessor [
+      Variable [ Name=sub ]
+      Field=subscription-id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [changeSet]
+    :
+    LiteralExpr [LONG] [1]
+  )
+  (
+    LiteralExpr [STRING] [execution-time]
+    :
+    FunctionCall twitter.current-datetime@0[
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message-text]
+    :
+    Variable [ Name=text ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetHistorySubscriptions]
+  ]
+  AS
+  Variable [ Name=sub ]
+,
+  (
+    SELECT ELEMENT [
+    Variable [ Name=tweet ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [TweetMessages]
+      ]
+      AS
+      Variable [ Name=tweet ]
+    ]
+    LetVariable [ Name=circle ]
+      :=
+      FunctionCall twitter.create-circle@2[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [location]
+        ]
+        LiteralExpr [DOUBLE] [30.0]
+      ]
+    Where
+      FunctionCall twitter.spatial-intersect@2[
+        FieldAccessor [
+          Variable [ Name=tweet ]
+          Field=sender-location
+        ]
+        Variable [ Name=circle ]
+      ]
+  )
+  AS
+  Variable [ Name=text ]
+]
+LetVariable [ Name=location ]
+  :=
+  FieldAccessor [
+    Variable [ Name=sub ]
+    Field=location
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_01.ast
new file mode 100644
index 0000000..f0bf3f7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_01.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData1(MyRecord) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index-join_rtree-spatial-intersect-point.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_02.ast
new file mode 100644
index 0000000..f6c641f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_02.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData1(MyRecord) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_02.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_03.ast
new file mode 100644
index 0000000..4494871
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-index-join/spatial-intersect-point_03.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/rtree-index-join_spatial-intersect-point_03.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-secondary-index-open.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-secondary-index-open.ast
new file mode 100644
index 0000000..644a3b8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-secondary-index-open.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index_rtree-secondary-index-open.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-secondary-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-secondary-index.ast
new file mode 100644
index 0000000..a283d04
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/rtree-secondary-index.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index_rtree-secondary-index.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete-all.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete-all.ast
new file mode 100644
index 0000000..ef75bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete-all.ast
@@ -0,0 +1,30 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32
+  }
+]
+DatasetDecl LineItems_q1(LineItemType) partitioned by [[l_orderkey]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete-rtree-secondary-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete-rtree-secondary-index.ast
new file mode 100644
index 0000000..ab52c9a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete-rtree-secondary-index.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete.ast
new file mode 100644
index 0000000..ef75bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-delete.ast
@@ -0,0 +1,30 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32
+  }
+]
+DatasetDecl LineItems_q1(LineItemType) partitioned by [[l_orderkey]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-insert-secondary-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-insert-secondary-index.ast
new file mode 100644
index 0000000..ef75bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-insert-secondary-index.ast
@@ -0,0 +1,30 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32
+  }
+]
+DatasetDecl LineItems_q1(LineItemType) partitioned by [[l_orderkey]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-insert.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-insert.ast
new file mode 100644
index 0000000..ef75bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/scan-insert.ast
@@ -0,0 +1,30 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32
+  }
+]
+DatasetDecl LineItems_q1(LineItemType) partitioned by [[l_orderkey]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_01.ast
new file mode 100644
index 0000000..9e0d9ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_01.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=ed ]
+    <=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_02.ast
new file mode 100644
index 0000000..9e04619
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_02.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    >=
+    Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_03.ast
new file mode 100644
index 0000000..8a045ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_03.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_03.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=ed ]
+    <
+    LiteralExpr [LONG] [3]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_04.ast
new file mode 100644
index 0000000..c79c629
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_04.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_04.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [3]
+    >
+    Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_05.ast
new file mode 100644
index 0000000..080a508
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_05.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_05.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=ed ]
+    >=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_06.ast
new file mode 100644
index 0000000..9dfd7fa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_06.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_06.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    <=
+    Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_07.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_07.ast
new file mode 100644
index 0000000..3595d15
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_07.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_07.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=ed ]
+    >
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_08.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_08.ast
new file mode 100644
index 0000000..eb03e16
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-let-to-edit-distance-check_08.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-let-to-edit-distance-check_08.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=ed ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    <
+    Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_01.ast
new file mode 100644
index 0000000..8b4917e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_01.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+    <=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_02.ast
new file mode 100644
index 0000000..0217bad
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_02.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    >=
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_03.ast
new file mode 100644
index 0000000..fe8097c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_03.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_03.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+    <
+    LiteralExpr [LONG] [3]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_04.ast
new file mode 100644
index 0000000..684dc9c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_04.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_04.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [3]
+    >
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_05.ast
new file mode 100644
index 0000000..5fc23b4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_05.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_05.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+    >=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_06.ast
new file mode 100644
index 0000000..9afcb14
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_06.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_06.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    <=
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_07.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_07.ast
new file mode 100644
index 0000000..92b6dfd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_07.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_07.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+    >
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_08.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_08.ast
new file mode 100644
index 0000000..78fa7c4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/edit-distance-to-edit-distance-check_08.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_edit-distance-to-edit-distance-check_08.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    <
+    FunctionCall test.edit-distance@2[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=authors
+      ]
+      LiteralExpr [STRING] [Michael J. Carey]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/fuzzyeq-to-edit-distance-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/fuzzyeq-to-edit-distance-check.ast
new file mode 100644
index 0000000..feeb848
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/fuzzyeq-to-edit-distance-check.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_fuzzyeq-to-edit-distance-check.adm
+Set simfunction=edit-distance
+Set simthreshold=1
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    ~=
+    LiteralExpr [STRING] [Michael J. Carey]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/fuzzyeq-to-jaccard-check.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/fuzzyeq-to-jaccard-check.ast
new file mode 100644
index 0000000..0d3fdb9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/fuzzyeq-to-jaccard-check.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_fuzzyeq-to-jaccard-check.adm
+Set simfunction=jaccard
+Set simthreshold=0.8f
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_01.ast
new file mode 100644
index 0000000..5b6462f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_01.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=jacc ]
+    >=
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_02.ast
new file mode 100644
index 0000000..dc65be9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_02.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    <=
+    Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_03.ast
new file mode 100644
index 0000000..9927d71
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_03.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=jacc ]
+    >
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_04.ast
new file mode 100644
index 0000000..914a2ff
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_04.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    <
+    Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_05.ast
new file mode 100644
index 0000000..78782ed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_05.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=jacc ]
+    <=
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_06.ast
new file mode 100644
index 0000000..212d775
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_06.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    >=
+    Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_07.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_07.ast
new file mode 100644
index 0000000..e468bc3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_07.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=jacc ]
+    <
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_08.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_08.ast
new file mode 100644
index 0000000..430cfb6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-let-to-jaccard-check_08.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-let-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=jacc ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    >
+    Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_01.ast
new file mode 100644
index 0000000..7ef3998
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_01.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_02.ast
new file mode 100644
index 0000000..516bdc1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_02.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    <=
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_03.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_03.ast
new file mode 100644
index 0000000..cab8170
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_03.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_02.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    >
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_04.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_04.ast
new file mode 100644
index 0000000..175601a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_04.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_03.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    <
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_05.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_05.ast
new file mode 100644
index 0000000..e9917ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_05.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_05.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    <=
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_06.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_06.ast
new file mode 100644
index 0000000..8be01dc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_06.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_06.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    >=
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_07.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_07.ast
new file mode 100644
index 0000000..27bd68c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_07.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_07.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+    <
+    LiteralExpr [FLOAT] [0.8]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_08.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_08.ast
new file mode 100644
index 0000000..155a8dd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/similarity/jaccard-to-jaccard-check_08.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/similarity_jaccard-to-jaccard-check_08.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    LiteralExpr [FLOAT] [0.8]
+    >
+    FunctionCall test.similarity-jaccard@2[
+      FunctionCall test.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=title
+        ]
+      ]
+      FunctionCall test.word-tokens@1[
+        LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/dont-skip-primary-index-search-in-delete.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/dont-skip-primary-index-search-in-delete.ast
new file mode 100644
index 0000000..e473596
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/dont-skip-primary-index-search-in-delete.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/dont-skip-primary-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/dont-skip-primary-index.ast
new file mode 100644
index 0000000..256f105
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/dont-skip-primary-index.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-primary-16.adm
+TypeDecl TestType [
+  open RecordType {
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[fname], [lname]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Craig]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      >=
+      LiteralExpr [STRING] [Kevin]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Mary]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=lname
+      ]
+      <=
+      LiteralExpr [STRING] [Tomes]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-ngram-index-search-in-delete.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-ngram-index-search-in-delete.ast
new file mode 100644
index 0000000..ac9fc6b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-ngram-index-search-in-delete.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-ngram-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-ngram-index.ast
new file mode 100644
index 0000000..ee9ee67
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-ngram-index.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_ngram-contains.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-rtree-index-search-in-delete.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-rtree-index-search-in-delete.ast
new file mode 100644
index 0000000..ab52c9a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-rtree-index-search-in-delete.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-rtree-secondary-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-rtree-secondary-index.ast
new file mode 100644
index 0000000..a283d04
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-rtree-secondary-index.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int32,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+WriteOutputTo nc1:rttest/index_rtree-secondary-index.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast
new file mode 100644
index 0000000..55c75c6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-57.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-search-in-delete.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-search-in-delete.ast
new file mode 100644
index 0000000..ecf76bf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-search-in-delete.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast
new file mode 100644
index 0000000..55c75c6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/btree-index_btree-secondary-57.adm
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[id]]
+Query:
+SELECT ELEMENT [
+Variable [ Name=emp ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      >=
+      LiteralExpr [STRING] [Max]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=emp ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Roger]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index-search-in-delete.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index-search-in-delete.ast
new file mode 100644
index 0000000..ac9fc6b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index-search-in-delete.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast
new file mode 100644
index 0000000..af1190f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+WriteOutputTo nc1:rttest/inverted-index-basic_word-jaccard.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
+Where
+  OperatorExpr [
+    Variable [ Name=jacc ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast
new file mode 100644
index 0000000..140b880
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast
@@ -0,0 +1,59 @@
+DataverseUse custlimit
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+WriteOutputTo nc1:/tmp/custlimit.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [custname]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [custage]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=age
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [10]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast
new file mode 100644
index 0000000..1369a6b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast
@@ -0,0 +1,392 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [left]
+    :
+    Variable [ Name=paperLeft ]
+  )
+  (
+    LiteralExpr [STRING] [right]
+    :
+    Variable [ Name=paperRight ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperLeft ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperRight ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idLeft]
+        :
+        Variable [ Name=idLeft ]
+      )
+      (
+        LiteralExpr [STRING] [idRight]
+        :
+        Variable [ Name=idRight ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperLeft ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensLeft]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenLeft]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenLeft ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperRight ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensRight]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenRight]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenRight ]
+    ]
+    LetVariable [ Name=lenLeft ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperLeft ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensLeft ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=lenRight ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperRight ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensRight ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensRight ]
+              Variable [ Name=lenRight ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenLeft ]
+        Variable [ Name=tokensLeft ]
+        Variable [ Name=lenRight ]
+        Variable [ Name=tokensRight ]
+        Variable [ Name=prefixTokenLeft ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenLeft ]
+          =
+          Variable [ Name=prefixTokenRight ]
+        ]
+        and
+        OperatorExpr [
+          OperatorExpr [
+            Variable [ Name=sim ]
+            >=
+            LiteralExpr [FLOAT] [0.5]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=id
+            ]
+            <
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=id
+            ]
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idLeft ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+      Variable [ Name=idRight ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensRight ]
+      Variable [ Name=lenRight ]
+      Variable [ Name=tokensLeft ]
+      Variable [ Name=lenLeft ]
+      Variable [ Name=paperLeft ]
+      Variable [ Name=paperRight ]
+      Variable [ Name=prefixTokenRight ]
+      Variable [ Name=prefixTokenLeft ]
+      Variable [ Name=paperLeft ]
+      Variable [ Name=paperRight ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idLeft
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idRight
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperLeft ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperRight ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast
new file mode 100644
index 0000000..c5360e2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast
@@ -0,0 +1,150 @@
+DataverseUse TinySocial
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int32,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int32>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+Query:
+LetVariable [ Name=lonelyusers ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=d ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=d ]
+    ]
+    Where
+      OperatorExpr [
+        FunctionCall TinySocial.count@1[
+          FieldAccessor [
+            Variable [ Name=d ]
+            Field=friend-ids
+          ]
+        ]
+        <
+        LiteralExpr [LONG] [2]
+      ]
+  )
+LetVariable [ Name=lonelyusers2 ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=d ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=d ]
+    ]
+    Where
+      OperatorExpr [
+        FunctionCall TinySocial.count@1[
+          FieldAccessor [
+            Variable [ Name=d ]
+            Field=friend-ids
+          ]
+        ]
+        <
+        LiteralExpr [LONG] [2]
+      ]
+  )
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user1]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=id
+        ]
+      )
+      (
+        LiteralExpr [STRING] [name]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=name
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [user2]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=l2 ]
+          Field=id
+        ]
+      )
+      (
+        LiteralExpr [STRING] [name]
+        :
+        FieldAccessor [
+          Variable [ Name=l2 ]
+          Field=name
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  Variable [ Name=lonelyusers ]
+  AS
+  Variable [ Name=l1 ]
+,
+  Variable [ Name=lonelyusers2 ]
+  AS
+  Variable [ Name=l2 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l1 ]
+      Field=id
+    ]
+    <
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=id
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=l2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast
new file mode 100644
index 0000000..6efe636
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/unnest-to-join_01.adm
+Query:
+SELECT ELEMENT [
+Variable [ Name=y ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  OrderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+  ]
+  AS
+  Variable [ Name=y ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    =
+    Variable [ Name=y ]
+  ]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast
new file mode 100644
index 0000000..c82765f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+WriteOutputTo nc1:rttest/unnest-to-join_02.adm
+Query:
+SELECT ELEMENT [
+QuantifiedExpression SOME [
+  [Variable [ Name=x ]
+  In
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+      LiteralExpr [LONG] [5]
+      LiteralExpr [LONG] [6]
+    ]
+  ]
+  [Variable [ Name=y ]
+  In
+    OrderedListConstructor [
+      LiteralExpr [LONG] [4]
+      LiteralExpr [LONG] [5]
+      LiteralExpr [LONG] [6]
+      LiteralExpr [LONG] [7]
+      LiteralExpr [LONG] [8]
+      LiteralExpr [LONG] [9]
+    ]
+  ]
+  Satifies [
+    OperatorExpr [
+      Variable [ Name=x ]
+      =
+      Variable [ Name=y ]
+    ]
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast
new file mode 100644
index 0000000..625892a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast
@@ -0,0 +1,90 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl TOKENSRANKEDADMType [
+  closed RecordType {
+    token : int32,
+    rank : int32
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl TOKENSRANKEDADM(TOKENSRANKEDADMType) partitioned by [[rank]]
+WriteOutputTo nc1:rttest/unnest_list_in_subplan.adm
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=tokenRanked ]
+      Field=rank
+    ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [TOKENSRANKEDADM]
+      ]
+      AS
+      Variable [ Name=tokenRanked ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        FieldAccessor [
+          Variable [ Name=tokenRanked ]
+          Field=token
+        ]
+      ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=tokenRanked ]
+        Field=rank
+      ]
+      ASC
+
+  )
diff --git a/asterix-app/src/test/resources/parserts/ignore.txt b/asterix-app/src/test/resources/parserts/ignore.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/ignore.txt
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/parserts/only.txt b/asterix-app/src/test/resources/parserts/only.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/only.txt
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/1.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/1.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/1.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/1.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/2.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/2.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/2.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/2.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/4.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/4.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/4.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/4.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/5.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/5.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/5.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/5.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/6.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/6.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/6.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/6.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/ANYInFieldAccessor.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/ANYInFieldAccessor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/ANYInFieldAccessor.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/ANYInFieldAccessor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/IfInFLOWGR.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/IfInFLOWGR.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/IfInFLOWGR.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/IfInFLOWGR.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/ListConstructor.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/ListConstructor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/ListConstructor.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/ListConstructor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/WithFrom.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/WithFrom.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/WithFrom.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/WithFrom.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/fieldAccessor.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/fieldAccessor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/fieldAccessor.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/fieldAccessor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/functionDecl1.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/functionDecl1.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/functionDecl1.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/functionDecl1.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR1.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR1.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR1.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR1.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR2.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR2.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR2.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR2.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR3.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR3.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR3.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/nestedFLWOGR3.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFor.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/nestedFor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFor.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/nestedFor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/numberInFieldAccessor.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/numberInFieldAccessor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/numberInFieldAccessor.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/numberInFieldAccessor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/union.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/union.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/union.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/union.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/variables.aql b/asterix-app/src/test/resources/parserts/queries-sql-like/variables.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries-sql-like/variables.aql
rename to asterix-app/src/test/resources/parserts/queries-sql-like/variables.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/1.aql b/asterix-app/src/test/resources/parserts/queries/1.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/1.aql
rename to asterix-app/src/test/resources/parserts/queries/1.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/2.aql b/asterix-app/src/test/resources/parserts/queries/2.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/2.aql
rename to asterix-app/src/test/resources/parserts/queries/2.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/4.aql b/asterix-app/src/test/resources/parserts/queries/4.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/4.aql
rename to asterix-app/src/test/resources/parserts/queries/4.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/5.aql b/asterix-app/src/test/resources/parserts/queries/5.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/5.aql
rename to asterix-app/src/test/resources/parserts/queries/5.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/6.aql b/asterix-app/src/test/resources/parserts/queries/6.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/6.aql
rename to asterix-app/src/test/resources/parserts/queries/6.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/ANYInFieldAccessor.aql b/asterix-app/src/test/resources/parserts/queries/ANYInFieldAccessor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/ANYInFieldAccessor.aql
rename to asterix-app/src/test/resources/parserts/queries/ANYInFieldAccessor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/IfInFLOWGR.aql b/asterix-app/src/test/resources/parserts/queries/IfInFLOWGR.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/IfInFLOWGR.aql
rename to asterix-app/src/test/resources/parserts/queries/IfInFLOWGR.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/IfThenElse.aql b/asterix-app/src/test/resources/parserts/queries/IfThenElse.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/IfThenElse.aql
rename to asterix-app/src/test/resources/parserts/queries/IfThenElse.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/LetFor.aql b/asterix-app/src/test/resources/parserts/queries/LetFor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/LetFor.aql
rename to asterix-app/src/test/resources/parserts/queries/LetFor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/ListConstructor.aql b/asterix-app/src/test/resources/parserts/queries/ListConstructor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/ListConstructor.aql
rename to asterix-app/src/test/resources/parserts/queries/ListConstructor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/addOperator.aql b/asterix-app/src/test/resources/parserts/queries/addOperator.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/addOperator.aql
rename to asterix-app/src/test/resources/parserts/queries/addOperator.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/constant.aql b/asterix-app/src/test/resources/parserts/queries/constant.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/constant.aql
rename to asterix-app/src/test/resources/parserts/queries/constant.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/createInternalDataSet.aql b/asterix-app/src/test/resources/parserts/queries/createInternalDataSet.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/createInternalDataSet.aql
rename to asterix-app/src/test/resources/parserts/queries/createInternalDataSet.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql b/asterix-app/src/test/resources/parserts/queries/del-dataset.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql
rename to asterix-app/src/test/resources/parserts/queries/del-dataset.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/fieldAccessor.aql b/asterix-app/src/test/resources/parserts/queries/fieldAccessor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/fieldAccessor.aql
rename to asterix-app/src/test/resources/parserts/queries/fieldAccessor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl.aql b/asterix-app/src/test/resources/parserts/queries/functionDecl.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/functionDecl.aql
rename to asterix-app/src/test/resources/parserts/queries/functionDecl.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl1.aql b/asterix-app/src/test/resources/parserts/queries/functionDecl1.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/functionDecl1.aql
rename to asterix-app/src/test/resources/parserts/queries/functionDecl1.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl2.aql b/asterix-app/src/test/resources/parserts/queries/functionDecl2.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/functionDecl2.aql
rename to asterix-app/src/test/resources/parserts/queries/functionDecl2.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl3.aql b/asterix-app/src/test/resources/parserts/queries/functionDecl3.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/functionDecl3.aql
rename to asterix-app/src/test/resources/parserts/queries/functionDecl3.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql b/asterix-app/src/test/resources/parserts/queries/load-del-dataset.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql
rename to asterix-app/src/test/resources/parserts/queries/load-del-dataset.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/mulOperator.aql b/asterix-app/src/test/resources/parserts/queries/mulOperator.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/mulOperator.aql
rename to asterix-app/src/test/resources/parserts/queries/mulOperator.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR.aql b/asterix-app/src/test/resources/parserts/queries/nestedFLWOGR.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR.aql
rename to asterix-app/src/test/resources/parserts/queries/nestedFLWOGR.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR1.aql b/asterix-app/src/test/resources/parserts/queries/nestedFLWOGR1.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR1.aql
rename to asterix-app/src/test/resources/parserts/queries/nestedFLWOGR1.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR2.aql b/asterix-app/src/test/resources/parserts/queries/nestedFLWOGR2.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR2.aql
rename to asterix-app/src/test/resources/parserts/queries/nestedFLWOGR2.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR3.aql b/asterix-app/src/test/resources/parserts/queries/nestedFLWOGR3.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR3.aql
rename to asterix-app/src/test/resources/parserts/queries/nestedFLWOGR3.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFor.aql b/asterix-app/src/test/resources/parserts/queries/nestedFor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/nestedFor.aql
rename to asterix-app/src/test/resources/parserts/queries/nestedFor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/numberInFieldAccessor.aql b/asterix-app/src/test/resources/parserts/queries/numberInFieldAccessor.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/numberInFieldAccessor.aql
rename to asterix-app/src/test/resources/parserts/queries/numberInFieldAccessor.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/union.aql b/asterix-app/src/test/resources/parserts/queries/union.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/union.aql
rename to asterix-app/src/test/resources/parserts/queries/union.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/utf-8.aql b/asterix-app/src/test/resources/parserts/queries/utf-8.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/utf-8.aql
rename to asterix-app/src/test/resources/parserts/queries/utf-8.aql
diff --git a/asterix-app/src/test/resources/AQLTS/queries/variables.aql b/asterix-app/src/test/resources/parserts/queries/variables.aql
similarity index 100%
rename from asterix-app/src/test/resources/AQLTS/queries/variables.aql
rename to asterix-app/src/test/resources/parserts/queries/variables.aql
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
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast
new file mode 100644
index 0000000..5615495
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast
@@ -0,0 +1,36 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=i ]
+        =
+        LiteralExpr [STRING] [movies]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast
new file mode 100644
index 0000000..f861640
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast
@@ -0,0 +1,112 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sig_name]
+    :
+    Variable [ Name=sig_name ]
+  )
+  (
+    LiteralExpr [STRING] [total_count]
+    :
+    Variable [ Name=sig_sponsorship_count ]
+  )
+  (
+    LiteralExpr [STRING] [chapter_breakdown]
+    :
+    Variable [ Name=by_chapter ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Event]
+  ]
+  AS
+  Variable [ Name=event ]
+,
+  FieldAccessor [
+    Variable [ Name=event ]
+    Field=sponsoring_sigs
+  ]
+  AS
+  Variable [ Name=sponsor ]
+]
+LetVariable [ Name=es ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [event]
+      :
+      Variable [ Name=event ]
+    )
+    (
+      LiteralExpr [STRING] [sponsor]
+      :
+      Variable [ Name=sponsor ]
+    )
+  ]
+Groupby
+  Variable [ Name=sig_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=sponsor ]
+    Field=sig_name
+  ]
+  With
+  Variable [ Name=es ]
+  Variable [ Name=sponsor ]
+  Variable [ Name=event ]
+
+LetVariable [ Name=sig_sponsorship_count ]
+  :=
+  FunctionCall null.count@1[
+    Variable [ Name=es ]
+  ]
+LetVariable [ Name=by_chapter ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [chapter_name]
+        :
+        Variable [ Name=chapter_name ]
+      )
+      (
+        LiteralExpr [STRING] [escount]
+        :
+        FunctionCall null.count@1[
+          Variable [ Name=es ]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=es ]
+      AS
+      Variable [ Name=e ]
+    ]
+    Groupby
+      Variable [ Name=chapter_name ]
+      :=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=e ]
+          Field=sponsor
+        ]
+        Field=chapter_name
+      ]
+      With
+      Variable [ Name=e ]
+      Variable [ Name=by_chapter ]
+      Variable [ Name=sig_sponsorship_count ]
+      Variable [ Name=es ]
+      Variable [ Name=sponsor ]
+      Variable [ Name=event ]
+
+  )
+Orderby
+  Variable [ Name=sig_sponsorship_count ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [5]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast
new file mode 100644
index 0000000..e739c37
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast
@@ -0,0 +1,67 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [similar_sigs]
+    :
+    Variable [ Name=similar_sigs ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [SIGroup]
+  ]
+  AS
+  Variable [ Name=sig ]
+]
+LetVariable [ Name=similar_sigs ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sig_name]
+        :
+        FieldAccessor [
+          Variable [ Name=similar_sig ]
+          Field=name
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [SIGroup]
+      ]
+      AS
+      Variable [ Name=similar_sig ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=similar_sig ]
+          !=
+          Variable [ Name=sig ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=similar_sig ]
+            Field=interests
+          ]
+          ~=
+          FieldAccessor [
+            Variable [ Name=sig ]
+            Field=interests
+          ]
+        ]
+      ]
+  )
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=sig ]
+      Field=name
+    ]
+    =
+    LiteralExpr [STRING] [Movie-Watchers]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast
new file mode 100644
index 0000000..73f0cd6
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast
@@ -0,0 +1,121 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [collocated_evnets]
+    :
+    Variable [ Name=collocated_events ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Event]
+  ]
+  AS
+  Variable [ Name=event ]
+]
+LetVariable [ Name=collocated_events ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [event_name]
+        :
+        FieldAccessor [
+          Variable [ Name=collocated_event ]
+          Field=name
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Events]
+      ]
+      AS
+      Variable [ Name=collocated_event ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=collocated_event ]
+              Field=location
+            ]
+            Field=street
+          ]
+          ~=
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=event ]
+              Field=location
+            ]
+            Field=street
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=collocated_event ]
+              Field=location
+            ]
+            Field=city
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=event ]
+              Field=location
+            ]
+            Field=city
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=collocated_event ]
+              Field=location
+            ]
+            Field=state
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=event ]
+              Field=location
+            ]
+            Field=state
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=collocated_event ]
+              Field=location
+            ]
+            Field=zip
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=event ]
+              Field=location
+            ]
+            Field=zip
+          ]
+        ]
+      ]
+  )
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=event ]
+      Field=name
+    ]
+    =
+    LiteralExpr [STRING] [The Night of the Ad Eaters, 29th edition]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast
new file mode 100644
index 0000000..dcbd485
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast
@@ -0,0 +1,83 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user_name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar_users]
+    :
+    Variable [ Name=similar_users ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Users]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+LetVariable [ Name=similar_users ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [user_name]
+        :
+        FieldAccessor [
+          Variable [ Name=similar_user ]
+          Field=name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [similarity]
+        :
+        Variable [ Name=similarity ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Users]
+      ]
+      AS
+      Variable [ Name=similar_user ]
+    ]
+    LetVariable [ Name=similarity ]
+      :=
+      FunctionCall null.jaccard_similarity@2[
+        FieldAccessor [
+          Variable [ Name=user ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=similar_user ]
+          Field=interests
+        ]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=user ]
+          !=
+          Variable [ Name=similar_user ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=similarity ]
+          >=
+          LiteralExpr [DOUBLE] [0.75]
+        ]
+      ]
+    Orderby
+      Variable [ Name=similarity ]
+      DESC
+
+    Limit
+      LiteralExpr [LONG] [10]
+  )
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast
new file mode 100644
index 0000000..2f60cbc
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast
@@ -0,0 +1,59 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [movie]
+    :
+    FieldAccessor [
+      Variable [ Name=mv ]
+      Field=movie
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Movie]
+  ]
+  AS
+  Variable [ Name=mv ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=movie
+        ]
+        =
+        IndexAccessor [
+          FieldAccessor [
+            Variable [ Name=mv ]
+            Field=movie
+          ]
+          Index: ANY
+        ]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast
new file mode 100644
index 0000000..4b9e932
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast
@@ -0,0 +1,32 @@
+Query:
+SELECT ELEMENT [
+IfExpr [
+  Condition:
+    OperatorExpr [
+      Variable [ Name=i ]
+      >
+      Variable [ Name=j ]
+    ]
+  Then:
+    Variable [ Name=i ]
+  Else:
+    Variable [ Name=j ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [LONG] [40]
+  ]
+  AS
+  Variable [ Name=i ]
+,
+  UnorderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+  ]
+  AS
+  Variable [ Name=j ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfThenElse.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfThenElse.ast
new file mode 100644
index 0000000..8c3462e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfThenElse.ast
@@ -0,0 +1,15 @@
+Query:
+SELECT ELEMENT [
+IfExpr [
+  Condition:
+    OperatorExpr [
+      LiteralExpr [LONG] [2]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  Then:
+    LiteralExpr [LONG] [20]
+  Else:
+    LiteralExpr [LONG] [10]
+]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast
new file mode 100644
index 0000000..b9bf49a
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast
@@ -0,0 +1,39 @@
+Query:
+LetVariable [ Name=users ]
+  :=
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  Variable [ Name=users ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=i ]
+        =
+        LiteralExpr [STRING] [movies]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast
new file mode 100644
index 0000000..3d3a387
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast
@@ -0,0 +1,24 @@
+Query:
+SELECT ELEMENT [
+OperatorExpr [
+  Variable [ Name=i ]
+  +
+  Variable [ Name=j ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+  ]
+  AS
+  Variable [ Name=i ]
+,
+  UnorderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+  ]
+  AS
+  Variable [ Name=j ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/addOperator.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/addOperator.ast
new file mode 100644
index 0000000..106d1f1
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/addOperator.ast
@@ -0,0 +1,8 @@
+Query:
+OperatorExpr [
+  LiteralExpr [LONG] [1]
+  +
+  LiteralExpr [LONG] [1]
+  -
+  LiteralExpr [LONG] [2]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
new file mode 100644
index 0000000..26addaa
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
@@ -0,0 +1,77 @@
+Query:
+SELECT [
+FunctionCall null.SQRT@1[
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=a
+    ]
+    *
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=b
+    ]
+  ]
+]
+root
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tbl_name]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  FunctionCall null.SQRT@1[
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=a
+      ]
+      *
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=b
+      ]
+    ]
+  ]
+  With
+  Variable [ Name=t ]
+
+LetVariable [ Name=u ]
+  :=
+  FunctionCall null.SQRT@1[
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=a
+      ]
+      *
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=b
+      ]
+    ]
+  ]
+ HAVING
+  OperatorExpr [
+    FunctionCall null.SQRT@1[
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=a
+        ]
+        *
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=b
+        ]
+      ]
+    ]
+    >
+    LiteralExpr [LONG] [0]
+  ]
+Orderby
+  Variable [ Name=u ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
new file mode 100644
index 0000000..90d32cc
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
@@ -0,0 +1,54 @@
+Query:
+SELECT [
+FunctionCall null.SQRT@1[
+  OperatorExpr [
+    FieldAccessor [
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [t]
+      ]
+      Field=a
+    ]
+    *
+    FieldAccessor [
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [t]
+      ]
+      Field=b
+    ]
+  ]
+]
+root
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tbl_name]
+  ]
+  AS
+  Variable [ Name=root ]
+]
+Groupby
+  FieldAccessor [
+    Variable [ Name=root ]
+    Field=id
+  ]
+  With
+  Variable [ Name=root ]
+
+LetVariable [ Name=u ]
+  :=
+  FieldAccessor [
+    Variable [ Name=root ]
+    Field=time
+  ]
+ HAVING
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=root ]
+      Field=orders
+    ]
+    >
+    LiteralExpr [LONG] [0]
+  ]
+Orderby
+  Variable [ Name=u ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
new file mode 100644
index 0000000..6b5693b
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
@@ -0,0 +1,82 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [root]
+    :
+    FunctionCall null.SQRT@1[
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=a
+        ]
+        *
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=b
+        ]
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tbl_name]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  FunctionCall null.SQRT@1[
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=a
+      ]
+      *
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=b
+      ]
+    ]
+  ]
+  With
+  Variable [ Name=t ]
+
+LetVariable [ Name=u ]
+  :=
+  FunctionCall null.SQRT@1[
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=a
+      ]
+      *
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=b
+      ]
+    ]
+  ]
+ HAVING
+  OperatorExpr [
+    FunctionCall null.SQRT@1[
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=a
+        ]
+        *
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=b
+        ]
+      ]
+    ]
+    >
+    LiteralExpr [LONG] [0]
+  ]
+Orderby
+  Variable [ Name=u ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast
new file mode 100644
index 0000000..78a13aa
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/constant.ast
@@ -0,0 +1,6 @@
+Query:
+OperatorExpr [
+  NEGATIVE LiteralExpr [LONG] [1]
+  +
+  LiteralExpr [LONG] [1]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/createInternalDataSet.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/createInternalDataSet.ast
new file mode 100644
index 0000000..cd320ddf
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/createInternalDataSet.ast
@@ -0,0 +1,2 @@
+DatasetDecl ds1(someType) partitioned by [[id]]
+DatasetDecl ds2(someType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/del-dataset.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/del-dataset.ast
new file mode 100644
index 0000000..849a30c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/del-dataset.ast
@@ -0,0 +1,22 @@
+DataverseUse demo0927
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast
new file mode 100644
index 0000000..40bc769
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast
@@ -0,0 +1,23 @@
+Query:
+LetVariable [ Name=bla ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [name]
+      :
+      LiteralExpr [STRING] [value]
+    )
+  ]
+SELECT ELEMENT [
+OperatorExpr [
+  FieldAccessor [
+    Variable [ Name=bla ]
+    Field=name
+  ]
+  =
+  FieldAccessor [
+    Variable [ Name=bla ]
+    Field=name
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast
new file mode 100644
index 0000000..192bf6e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast
@@ -0,0 +1,12 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [30]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast
new file mode 100644
index 0000000..e768f7e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast
@@ -0,0 +1,12 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  UnorderedListConstructor [
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [30]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast
new file mode 100644
index 0000000..b354122
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=r ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [sensors]
+  ]
+  AS
+  Variable [ Name=s ]
+  INNER UNNEST
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=readings
+    ]
+     AS
+    Variable [ Name=r ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast
new file mode 100644
index 0000000..7668550
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT [
+FieldAccessor [
+  Variable [ Name=s ]
+  Field=sensor
+]
+sensor
+Variable [ Name=r ]
+reading
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [sensors]
+  ]
+  AS
+  Variable [ Name=s ]
+,
+  FieldAccessor [
+    Variable [ Name=s ]
+    Field=readings
+  ]
+  AS
+  Variable [ Name=r ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast
new file mode 100644
index 0000000..2a3a239
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+SELECT [
+FieldAccessor [
+  Variable [ Name=m ]
+  Field=sensor
+]
+sensor
+FieldAccessor [
+  Variable [ Name=s ]
+  Field=readings
+]
+readings
+FieldAccessor [
+  Variable [ Name=m ]
+  Field=location
+]
+location
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [sensors]
+  ]
+  AS
+  Variable [ Name=s ]
+  INNER JOIN
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [sensorMeta]
+    ]
+    AS
+    Variable [ Name=m ]
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=s ]
+        Field=sensor
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=sensor
+      ]
+    ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast
new file mode 100644
index 0000000..9fd948a
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast
@@ -0,0 +1,157 @@
+DataverseUse test_022
+Query:
+SELECT [
+FieldAccessor [
+  Variable [ Name=sl ]
+  Field=location
+]
+location
+FieldAccessor [
+  Variable [ Name=sr ]
+  Field=gas
+]
+gas
+FieldAccessor [
+  Variable [ Name=sr ]
+  Field=readings
+]
+readings
+]
+FROM [  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [1]
+      )
+      (
+        LiteralExpr [STRING] [location]
+        :
+        FunctionCall test_022.point@1[
+          LiteralExpr [STRING] [0.0,0.0]
+        ]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [2]
+      )
+      (
+        LiteralExpr [STRING] [location]
+        :
+        FunctionCall test_022.point@1[
+          LiteralExpr [STRING] [0.0,1.0]
+        ]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [3]
+      )
+      (
+        LiteralExpr [STRING] [location]
+        :
+        FunctionCall test_022.point@1[
+          LiteralExpr [STRING] [0.0,1.0]
+        ]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=sl ]
+  LEFTOUTER UNNEST
+    UnorderedListConstructor [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          LiteralExpr [LONG] [1]
+        )
+        (
+          LiteralExpr [STRING] [sensor]
+          :
+          LiteralExpr [LONG] [1]
+        )
+        (
+          LiteralExpr [STRING] [gas]
+          :
+          LiteralExpr [STRING] [co2]
+        )
+        (
+          LiteralExpr [STRING] [readings]
+          :
+          UnorderedListConstructor [
+            LiteralExpr [DOUBLE] [0.2]
+            LiteralExpr [DOUBLE] [0.3]
+          ]
+        )
+      ]
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          LiteralExpr [LONG] [2]
+        )
+        (
+          LiteralExpr [STRING] [sensor]
+          :
+          LiteralExpr [LONG] [2]
+        )
+        (
+          LiteralExpr [STRING] [gas]
+          :
+          LiteralExpr [STRING] [co2]
+        )
+        (
+          LiteralExpr [STRING] [readings]
+          :
+          UnorderedListConstructor [
+            LiteralExpr [DOUBLE] [0.4]
+            LiteralExpr [DOUBLE] [0.2]
+          ]
+        )
+      ]
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          LiteralExpr [LONG] [3]
+        )
+        (
+          LiteralExpr [STRING] [sensor]
+          :
+          LiteralExpr [LONG] [2]
+        )
+        (
+          LiteralExpr [STRING] [gas]
+          :
+          LiteralExpr [STRING] [no2]
+        )
+        (
+          LiteralExpr [STRING] [readings]
+          :
+          UnorderedListConstructor [
+            LiteralExpr [DOUBLE] [0.1]
+          ]
+        )
+      ]
+    ]
+     AS
+    Variable [ Name=sr ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=sl ]
+      Field=sensor
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=sr ]
+      Field=sensor
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast
new file mode 100644
index 0000000..9ace3b5
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast
@@ -0,0 +1,59 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=r ]
+]
+FROM [  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [1]
+      )
+      (
+        LiteralExpr [STRING] [readings]
+        :
+        UnorderedListConstructor [
+          LiteralExpr [DOUBLE] [0.2]
+          LiteralExpr [DOUBLE] [0.3]
+        ]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [2]
+      )
+      (
+        LiteralExpr [STRING] [readings]
+        :
+        UnorderedListConstructor [
+          LiteralExpr [DOUBLE] [0.4]
+          LiteralExpr [DOUBLE] [0.2]
+        ]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [3]
+      )
+      (
+        LiteralExpr [STRING] [readings]
+        :
+        UnorderedListConstructor [
+        ]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=s ]
+  LEFTOUTER UNNEST
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=readings
+    ]
+     AS
+    Variable [ Name=r ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast
new file mode 100644
index 0000000..69745a5
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast
@@ -0,0 +1,156 @@
+DataverseUse test_021
+Query:
+SELECT [
+FieldAccessor [
+  Variable [ Name=sl ]
+  Field=location
+]
+location
+FieldAccessor [
+  Variable [ Name=sr ]
+  Field=gas
+]
+gas
+FieldAccessor [
+  Variable [ Name=sr ]
+  Field=readings
+]
+readings
+]
+FROM [  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [1]
+      )
+      (
+        LiteralExpr [STRING] [location]
+        :
+        FunctionCall test_021.point@1[
+          LiteralExpr [STRING] [0.0,0.0]
+        ]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [2]
+      )
+      (
+        LiteralExpr [STRING] [location]
+        :
+        FunctionCall test_021.point@1[
+          LiteralExpr [STRING] [0.0,1.0]
+        ]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sensor]
+        :
+        LiteralExpr [LONG] [3]
+      )
+      (
+        LiteralExpr [STRING] [location]
+        :
+        FunctionCall test_021.point@1[
+          LiteralExpr [STRING] [0.0,1.0]
+        ]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=sl ]
+  LEFTOUTER JOIN
+    UnorderedListConstructor [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          LiteralExpr [LONG] [1]
+        )
+        (
+          LiteralExpr [STRING] [sensor]
+          :
+          LiteralExpr [LONG] [1]
+        )
+        (
+          LiteralExpr [STRING] [gas]
+          :
+          LiteralExpr [STRING] [co2]
+        )
+        (
+          LiteralExpr [STRING] [readings]
+          :
+          UnorderedListConstructor [
+            LiteralExpr [DOUBLE] [0.2]
+            LiteralExpr [DOUBLE] [0.3]
+          ]
+        )
+      ]
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          LiteralExpr [LONG] [2]
+        )
+        (
+          LiteralExpr [STRING] [sensor]
+          :
+          LiteralExpr [LONG] [2]
+        )
+        (
+          LiteralExpr [STRING] [gas]
+          :
+          LiteralExpr [STRING] [co2]
+        )
+        (
+          LiteralExpr [STRING] [readings]
+          :
+          UnorderedListConstructor [
+            LiteralExpr [DOUBLE] [0.4]
+            LiteralExpr [DOUBLE] [0.2]
+          ]
+        )
+      ]
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          LiteralExpr [LONG] [3]
+        )
+        (
+          LiteralExpr [STRING] [sensor]
+          :
+          LiteralExpr [LONG] [2]
+        )
+        (
+          LiteralExpr [STRING] [gas]
+          :
+          LiteralExpr [STRING] [no2]
+        )
+        (
+          LiteralExpr [STRING] [readings]
+          :
+          UnorderedListConstructor [
+            LiteralExpr [DOUBLE] [0.1]
+          ]
+        )
+      ]
+    ]
+    AS
+    Variable [ Name=sr ]
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=sl ]
+        Field=sensor
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=sr ]
+        Field=sensor
+      ]
+    ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast
new file mode 100644
index 0000000..bb0c8b5
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast
@@ -0,0 +1,20 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [10]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    =
+    LiteralExpr [LONG] [10]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast
new file mode 100644
index 0000000..e025413
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast
@@ -0,0 +1,16 @@
+FunctionDecl add([a, b]) {
+  OperatorExpr [
+    Variable [ Name=a ]
+    +
+    Variable [ Name=b ]
+  ]
+}
+
+FunctionDecl minus([a, b]) {
+  OperatorExpr [
+    Variable [ Name=a ]
+    -
+    Variable [ Name=b ]
+  ]
+}
+
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast
new file mode 100644
index 0000000..36f35dd
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast
@@ -0,0 +1,114 @@
+FunctionDecl calculate([events]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [sig_name]
+        :
+        Variable [ Name=sig_name ]
+      )
+      (
+        LiteralExpr [STRING] [total_count]
+        :
+        Variable [ Name=sig_sponsorship_count ]
+      )
+      (
+        LiteralExpr [STRING] [chapter_breakdown]
+        :
+        Variable [ Name=by_chapter ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=events ]
+      AS
+      Variable [ Name=event ]
+,
+      FieldAccessor [
+        Variable [ Name=event ]
+        Field=sponsoring_sigs
+      ]
+      AS
+      Variable [ Name=sponsor ]
+    ]
+    LetVariable [ Name=es ]
+      :=
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [event]
+          :
+          Variable [ Name=event ]
+        )
+        (
+          LiteralExpr [STRING] [sponsor]
+          :
+          Variable [ Name=sponsor ]
+        )
+      ]
+    Groupby
+      Variable [ Name=sig_name ]
+      :=
+      FieldAccessor [
+        Variable [ Name=sponsor ]
+        Field=sig_name
+      ]
+
+    LetVariable [ Name=sig_sponsorship_count ]
+      :=
+      FunctionCall null.count@1[
+        Variable [ Name=es ]
+      ]
+    LetVariable [ Name=by_chapter ]
+      :=
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [chapter_name]
+            :
+            Variable [ Name=chapter_name ]
+          )
+          (
+            LiteralExpr [STRING] [escount]
+            :
+            FunctionCall null.count@1[
+              Variable [ Name=es ]
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=es ]
+          AS
+          Variable [ Name=e ]
+        ]
+        Groupby
+          Variable [ Name=chapter_name ]
+          :=
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=e ]
+              Field=sponsor
+            ]
+            Field=chapter_name
+          ]
+
+      )
+    Orderby
+      Variable [ Name=sig_sponsorship_count ]
+      DESC
+
+    Limit
+      LiteralExpr [LONG] [5]
+  )
+}
+
+Query:
+LetVariable [ Name=result ]
+  :=
+  FunctionCall null.calculate@1[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [Events]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast
new file mode 100644
index 0000000..407d545
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast
@@ -0,0 +1,15 @@
+FunctionDecl GT([a, b]) {
+  IfExpr [
+    Condition:
+      OperatorExpr [
+        Variable [ Name=a ]
+        >
+        Variable [ Name=b ]
+      ]
+    Then:
+      LiteralExpr [TRUE]
+    Else:
+      LiteralExpr [FALSE]
+  ]
+}
+
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast
new file mode 100644
index 0000000..487c466
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast
@@ -0,0 +1,9 @@
+FunctionDecl function with spaces([a, b]) {
+  LiteralExpr [STRING] [string with spaces]
+}
+
+Query:
+FunctionCall null.function with spaces@2[
+  LiteralExpr [LONG] [1]
+  LiteralExpr [LONG] [2]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast
new file mode 100644
index 0000000..b413291
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast
@@ -0,0 +1,93 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.count@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [gas]
+        :
+        LiteralExpr [STRING] [co]
+      )
+      (
+        LiteralExpr [STRING] [num]
+        :
+        LiteralExpr [DOUBLE] [0.1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [gas]
+        :
+        LiteralExpr [STRING] [co]
+      )
+      (
+        LiteralExpr [STRING] [num]
+        :
+        LiteralExpr [DOUBLE] [0.2]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [gas]
+        :
+        LiteralExpr [STRING] [co]
+      )
+      (
+        LiteralExpr [STRING] [num]
+        :
+        LiteralExpr [DOUBLE] [0.3]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [gas]
+        :
+        LiteralExpr [STRING] [co2]
+      )
+      (
+        LiteralExpr [STRING] [num]
+        :
+        LiteralExpr [DOUBLE] [0.4]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [gas]
+        :
+        LiteralExpr [STRING] [no2]
+      )
+      (
+        LiteralExpr [STRING] [num]
+        :
+        LiteralExpr [DOUBLE] [0.5]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [gas]
+        :
+        LiteralExpr [STRING] [no2]
+      )
+      (
+        LiteralExpr [STRING] [num]
+        :
+        LiteralExpr [DOUBLE] [0.6]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Groupby
+  Variable [ Name=g ]
+  :=
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=gas
+  ]
+  With
+  Variable [ Name=r ]
+
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/load-del-dataset.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/load-del-dataset.ast
new file mode 100644
index 0000000..849a30c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/load-del-dataset.ast
@@ -0,0 +1,22 @@
+DataverseUse demo0927
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int32,
+        total : float
+      }
+
+  }
+]
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/mulOperator.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/mulOperator.ast
new file mode 100644
index 0000000..42be275
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/mulOperator.ast
@@ -0,0 +1,12 @@
+Query:
+OperatorExpr [
+  LiteralExpr [LONG] [1]
+  +
+  OperatorExpr [
+    LiteralExpr [LONG] [2]
+    *
+    LiteralExpr [LONG] [3]
+  ]
+  -
+  LiteralExpr [LONG] [4]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast
new file mode 100644
index 0000000..6e7af3a
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast
@@ -0,0 +1,43 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  (
+    LetVariable [ Name=data ]
+      :=
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [User]
+      ]
+    SELECT ELEMENT [
+    Variable [ Name=data ]
+    ]
+  )
+  AS
+  Variable [ Name=user ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=i ]
+        =
+        LiteralExpr [STRING] [movies]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast
new file mode 100644
index 0000000..46d3fb8
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast
@@ -0,0 +1,46 @@
+Query:
+SELECT ELEMENT [
+(
+  SELECT ELEMENT [
+  Variable [ Name=k ]
+  ]
+  FROM [    IfExpr [
+      Condition:
+        OperatorExpr [
+          Variable [ Name=i ]
+          >
+          Variable [ Name=j ]
+        ]
+      Then:
+        Variable [ Name=i ]
+      Else:
+        Variable [ Name=j ]
+    ]
+    AS
+    Variable [ Name=k ]
+  ]
+  Where
+    OperatorExpr [
+      Variable [ Name=k ]
+      <
+      LiteralExpr [LONG] [10]
+    ]
+)
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [LONG] [40]
+  ]
+  AS
+  Variable [ Name=i ]
+,
+  UnorderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+  ]
+  AS
+  Variable [ Name=j ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast
new file mode 100644
index 0000000..9673c91
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast
@@ -0,0 +1,56 @@
+Query:
+SELECT ELEMENT [
+(
+  SELECT ELEMENT [
+  Variable [ Name=k ]
+  ]
+  FROM [    IfExpr [
+      Condition:
+        OperatorExpr [
+          Variable [ Name=i ]
+          >
+          Variable [ Name=j ]
+        ]
+      Then:
+        Variable [ Name=i ]
+      Else:
+        Variable [ Name=j ]
+    ]
+    AS
+    Variable [ Name=k ]
+  ]
+  Where
+    OperatorExpr [
+      Variable [ Name=k ]
+      <
+      LiteralExpr [LONG] [10]
+    ]
+)
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [30]
+    (
+      SELECT ELEMENT [
+      Variable [ Name=tmp ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [number]
+        ]
+        AS
+        Variable [ Name=tmp ]
+      ]
+    )
+  ]
+  AS
+  Variable [ Name=i ]
+,
+  UnorderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+  ]
+  AS
+  Variable [ Name=j ]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast
new file mode 100644
index 0000000..b798bc6
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast
@@ -0,0 +1,114 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sig_name]
+    :
+    Variable [ Name=sig_name ]
+  )
+  (
+    LiteralExpr [STRING] [total_count]
+    :
+    Variable [ Name=sig_sponsorship_count ]
+  )
+  (
+    LiteralExpr [STRING] [chapter_breakdown]
+    :
+    Variable [ Name=by_chapter ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Event]
+  ]
+  AS
+  Variable [ Name=event ]
+,
+  FieldAccessor [
+    Variable [ Name=event ]
+    Field=sponsoring_sigs
+  ]
+  AS
+  Variable [ Name=sponsor ]
+]
+LetVariable [ Name=es ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [event]
+      :
+      Variable [ Name=event ]
+    )
+    (
+      LiteralExpr [STRING] [sponsor]
+      :
+      Variable [ Name=sponsor ]
+    )
+  ]
+Groupby
+  Variable [ Name=sig_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=sponsor ]
+    Field=sig_name
+  ]
+  With
+  Variable [ Name=es ]
+  Variable [ Name=sponsor ]
+  Variable [ Name=event ]
+
+LetVariable [ Name=sig_sponsorship_count ]
+  :=
+  FunctionCall null.count@1[
+    Variable [ Name=es ]
+  ]
+LetVariable [ Name=by_chapter ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [chapter_name]
+        :
+        Variable [ Name=chapter_name ]
+      )
+      (
+        LiteralExpr [STRING] [escount]
+        :
+        FunctionCall null.count@1[
+          Variable [ Name=es ]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=es ]
+      AS
+      Variable [ Name=e ]
+    ]
+    Groupby
+      Variable [ Name=chapter_name ]
+      :=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=e ]
+          Field=sponsor
+        ]
+        Field=chapter_name
+      ]
+      With
+      Variable [ Name=e ]
+      Variable [ Name=by_chapter ]
+      Variable [ Name=sig_sponsorship_count ]
+      Variable [ Name=es ]
+      Variable [ Name=sponsor ]
+      Variable [ Name=event ]
+
+  )
+Orderby
+  Variable [ Name=sig_sponsorship_count ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [5]
+  Offset
+    LiteralExpr [LONG] [2]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast
new file mode 100644
index 0000000..518d51b
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast
@@ -0,0 +1,56 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [movie]
+    :
+    FieldAccessor [
+      Variable [ Name=mv ]
+      Field=movie
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Movie]
+  ]
+  AS
+  Variable [ Name=mv ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=movie
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=mv ]
+          Field=movie
+        ]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast
new file mode 100644
index 0000000..38846d5
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast
@@ -0,0 +1,62 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [movie]
+    :
+    FieldAccessor [
+      Variable [ Name=mv ]
+      Field=movie
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Movie]
+  ]
+  AS
+  Variable [ Name=mv ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=movie
+        ]
+        =
+        IndexAccessor [
+          FieldAccessor [
+            Variable [ Name=mv ]
+            Field=movie
+          ]
+          Index:           FieldAccessor [
+            Variable [ Name=mv ]
+            Field=movie
+          ]
+        ]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/select_clause_sugar.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/select_clause_sugar.ast
new file mode 100644
index 0000000..6622fe1
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/select_clause_sugar.ast
@@ -0,0 +1,21 @@
+Query:
+SELECT [
+Variable [ Name=x ]
+value
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [10]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    =
+    LiteralExpr [LONG] [10]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/select_from_where_sugar.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/select_from_where_sugar.ast
new file mode 100644
index 0000000..bb0c8b5
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/select_from_where_sugar.ast
@@ -0,0 +1,20 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [10]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    =
+    LiteralExpr [LONG] [10]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav.ast
new file mode 100644
index 0000000..303a19d
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav.ast
@@ -0,0 +1,11 @@
+Query:
+FieldAccessor [
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [id]
+      :
+      LiteralExpr [LONG] [1]
+    )
+  ]
+  Field=name
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_delimited_identifier.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_delimited_identifier.ast
new file mode 100644
index 0000000..d2d46e9
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_delimited_identifier.ast
@@ -0,0 +1,11 @@
+Query:
+FieldAccessor [
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [e]
+      :
+      LiteralExpr [LONG] [1]
+    )
+  ]
+  Field=e
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_mutiple_steps.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_mutiple_steps.ast
new file mode 100644
index 0000000..8e60aa9
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_mutiple_steps.ast
@@ -0,0 +1,39 @@
+Query:
+FieldAccessor [
+  FieldAccessor [
+    FieldAccessor [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [n]
+          :
+          LiteralExpr [LONG] [1]
+        )
+        (
+          LiteralExpr [STRING] [a1 a2]
+          :
+          RecordConstructor [
+            (
+              LiteralExpr [STRING] [n]
+              :
+              LiteralExpr [LONG] [2]
+            )
+            (
+              LiteralExpr [STRING] [b1 b2]
+              :
+              RecordConstructor [
+                (
+                  LiteralExpr [STRING] [n]
+                  :
+                  LiteralExpr [LONG] [3]
+                )
+              ]
+            )
+          ]
+        )
+      ]
+      Field=a1 a2
+    ]
+    Field=b1 b2
+  ]
+  Field=n
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_quotes.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_quotes.ast
new file mode 100644
index 0000000..930ebf5
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/tuple_nav_quotes.ast
@@ -0,0 +1,11 @@
+Query:
+FieldAccessor [
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [author-id]
+      :
+      LiteralExpr [LONG] [2]
+    )
+  ]
+  Field=author-id
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/union.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/union.ast
new file mode 100644
index 0000000..ef69119
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/union.ast
@@ -0,0 +1,27 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall null.foo1@0[
+  ]
+  AS
+  Variable [ Name=l ]
+]
+UNION ALL 
+  SELECT ELEMENT [
+  Variable [ Name=l ]
+  ]
+  FROM [    FunctionCall null.foo2@0[
+    ]
+    AS
+    Variable [ Name=l ]
+  ]
+UNION ALL 
+  SELECT ELEMENT [
+  Variable [ Name=l ]
+  ]
+  FROM [    FunctionCall null.foo3@0[
+    ]
+    AS
+    Variable [ Name=l ]
+  ]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/utf-8.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/utf-8.ast
new file mode 100644
index 0000000..50d1e0b
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/utf-8.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.string_to_codepoint@1[
+  LiteralExpr [STRING] [äöß]
+]
+Query:
+FunctionCall null.string_to_codepoint@1[
+  LiteralExpr [STRING] [è¿Ž]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast
new file mode 100644
index 0000000..330ebef
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/variables.ast
@@ -0,0 +1,14 @@
+Query:
+LetVariable [ Name=a ]
+  :=
+  LiteralExpr [LONG] [1]
+LetVariable [ Name=b ]
+  :=
+  LiteralExpr [LONG] [1]
+SELECT ELEMENT [
+OperatorExpr [
+  Variable [ Name=b ]
+  -
+  Variable [ Name=a ]
+]
+]
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/where_clause.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/where_clause.ast
new file mode 100644
index 0000000..57c1c2c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/where_clause.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=r ]
+  Field=reading
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [sensors]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=reading
+    ]
+    =
+    LiteralExpr [DOUBLE] [0.2]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.aql
index 7dedc17..2fd67a7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.aql
@@ -27,6 +27,8 @@
 drop dataverse test if exists;
 create dataverse test;
 
+use dataverse test;
+
 create type test.Emp as closed {
 id: int64,
 fname: string,
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.1.ddl.sqlpp
new file mode 100644
index 0000000..6ac6cb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.1.ddl.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.
+ */
+/*
+* Description  : Run aggregates over both ordered list and unordered list with only null items.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.sqlpp
new file mode 100644
index 0000000..4529b3c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null/agg_null.3.query.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.
+ */
+/*
+* Description  : Run aggregates over both ordered list and unordered list with only null items.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+{'sql-count1':"sql-count"([null]),'average1':"sql-avg"([null]),'sql-sum1':"sql-sum"([null]),'sql-min1':"sql-min"([null]),'sql-max1':"sql-max"([null]),'sql-count2':"sql-count"({{null,null}}),'average2':"sql-avg"({{null,null}}),'sql-sum2':"sql-sum"({{null,null}}),'sql-min2':"sql-min"({{null,null}}),'sql-max2':"sql-max"({{null,null}})};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.1.ddl.sqlpp
new file mode 100644
index 0000000..3f586d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.2.update.sqlpp
new file mode 100644
index 0000000..a2517aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.2.update.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.
+ */
+/*
+* Description  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+use test;
+
+
+insert into Test
+select element {'id':0,'val':4.32,'valplus':21};
+insert into Test
+select element {'id':1,'val':5.32};
+insert into Test
+select element {'id':2,'val':6.32,'valplus':31};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp
new file mode 100644
index 0000000..f720a2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+use test;
+
+
+{'sql-count':test."sql-count"((
+    select element t.valplus
+    from  Test as t
+)),'average':test."sql-avg"((
+    select element t.valplus
+    from  Test as t
+)),'sql-sum':test."sql-sum"((
+    select element t.valplus
+    from  Test as t
+)),'sql-min':test."sql-min"((
+    select element t.valplus
+    from  Test as t
+)),'sql-max':test."sql-max"((
+    select element t.valplus
+    from  Test as t
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.1.ddl.sqlpp
new file mode 100644
index 0000000..3f586d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.2.update.sqlpp
new file mode 100644
index 0000000..6f72b89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.2.update.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.
+ */
+/*
+* Description  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+use test;
+
+
+insert into Test
+select element {'id':0,'val':4.32,'valplus':473847};
+insert into Test
+select element {'id':1,'val':5.32};
+insert into Test
+select element {'id':2,'val':6.32,'valplus':38473827484738239};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
new file mode 100644
index 0000000..bec4d87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+use test;
+
+
+{'sql-count':test."sql-count"((
+    select element t
+    from  Test as t
+)),'average':test."sql-avg"((
+    select element i.val
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'sql-sum':test."sql-sum"((
+    select element i.val
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'sql-min':test."sql-min"((
+    select element i.valplus
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'sql-max':test."sql-max"((
+    select element i.valplus
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.1.ddl.sqlpp
new file mode 100644
index 0000000..2fa4008
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.1.ddl.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.
+ */
+/*
+* Description  : Run aggregates over an ordered list with numbers of different types
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.sqlpp
new file mode 100644
index 0000000..dc464a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number/agg_number.3.query.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.
+ */
+/*
+* Description  : Run aggregates over an ordered list with numbers of different types
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+{'sql-count1':"sql-count"([float('2.0'),double('3.0'),93847382783847382,1]),'average1':"sql-avg"([float('2.0'),double('3.0'),93847382783847382,1]),'sql-sum1':"sql-sum"([float('2.0'),double('3.0'),93847382783847382,1]),'sql-min1':"sql-min"([float('2.0'),double('3.0'),93847382783847382,1]),'sql-max1':"sql-max"([float('2.0'),double('3.0'),93847382783847382,1]),'sql-count2':"sql-count"({{float('2.0'),double('3.0'),93847382783847382,1}}),'average2':"sql-avg"({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-sum2':"sql-sum"({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-min2':"sql-min"({{float('2.0'),double('3.0'),93847382783847382,1}}),'sql-max2':"sql-max"({{float('2.0'),double('3.0'),93847382783847382,1}})};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.1.ddl.sqlpp
new file mode 100644
index 0000000..08fcde8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.2.update.sqlpp
new file mode 100644
index 0000000..3578271
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.2.update.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.
+ */
+/*
+* Description  : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+use test;
+
+
+insert into Test
+select element {'id':0,'val':4.32,'valplus':2};
+insert into Test
+select element {'id':1,'val':5.32,'valplus':32.98};
+insert into Test
+select element {'id':2,'val':6.32,'valplus':38473827484738239};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp
new file mode 100644
index 0000000..f57bba5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date         : Feb 7th 2014
+*/
+
+use test;
+
+
+{'sql-count':test."sql-count"((
+    select element t.valplus
+    from  Test as t
+)),'average':test."sql-avg"((
+    select element t.valplus
+    from  Test as t
+)),'sql-sum':test."sql-sum"((
+    select element t.valplus
+    from  Test as t
+)),'sql-min':test."sql-min"((
+    select element t.valplus
+    from  Test as t
+)),'sql-max':test."sql-max"((
+    select element t.valplus
+    from  Test as t
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.3.query.sqlpp
new file mode 100644
index 0000000..f6db917
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double/avg_double.3.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.
+ */
+
+select element "sql-avg"((
+    select element x
+    from  [1.0,2.0,double('3.0')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.3.query.sqlpp
new file mode 100644
index 0000000..9f70bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_double_null/avg_double_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test."sql-avg"((
+    select element x.doubleField
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..a71e263
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that sql-avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..ddc1233
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..47e1388
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that sql-avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..360c6db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that sql-avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..c0377fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..2163d70
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.3.query.sqlpp
new file mode 100644
index 0000000..211efca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float/avg_float.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.3.query.sqlpp
new file mode 100644
index 0000000..e2005b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.3.query.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.
+ */
+
+use test;
+
+
+{'average':test."sql-avg"((
+    select element x.floatField
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.3.query.sqlpp
new file mode 100644
index 0000000..36ee77a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16/avg_int16.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x
+    from  [test.int16('1'),test.int16('2'),test.int16('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..727455a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test."sql-avg"((
+    select element x.int16Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.3.query.sqlpp
new file mode 100644
index 0000000..f7837ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32/avg_int32.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x
+    from  [test.int32('1'),test.int32('2'),test.int32('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..41faea7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test."sql-avg"((
+    select element x.int32Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.3.query.sqlpp
new file mode 100644
index 0000000..6694f52
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64/avg_int64.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x
+    from  [test.int64('1'),test.int64('2'),test.int64('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..bc44cba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test."sql-avg"((
+    select element x.int64Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.3.query.sqlpp
new file mode 100644
index 0000000..7acc346
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8/avg_int8.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-avg"((
+    select element x
+    from  [test.int8('1'),test.int8('2'),test.int8('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..89f1dc9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test."sql-avg"((
+    select element x.int8Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..5378c3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ddl.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.
+ */
+/*
+* Description  : Run sql-avg over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp
new file mode 100644
index 0000000..f02d73b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run sql-avg over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
+select element "sql-avg"((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.3.query.sqlpp
new file mode 100644
index 0000000..47ed1d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_01/count_01.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-count"((
+    select element x
+    from  [1,2,3] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..34b3e00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.1.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..b0903c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..7038ffc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_01/count_empty_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+select element "sql-count"((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..8450cbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that sql-count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..2fe949f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..a8cbd64
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_empty_02/count_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-count"((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.3.query.sqlpp
new file mode 100644
index 0000000..afb7f99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/count_null/count_null.3.query.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.
+ */
+
+use test;
+
+
+{'sql-count':test."sql-count"((
+    select element x.doubleField
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.1.ddl.sqlpp
new file mode 100644
index 0000000..69289cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+{
+  id : int64,
+  name : string?
+}
+
+create  table Employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.2.update.sqlpp
new file mode 100644
index 0000000..59fbfb3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.2.update.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.
+ */
+
+use test;
+
+
+insert into Employee
+select element {'id':12,'name':'John Doe'};
+insert into Employee
+select element {'id':42};
+insert into Employee
+select element {'id':22,'name':'John Smith'};
+insert into Employee
+select element {'id':19};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.3.query.sqlpp
new file mode 100644
index 0000000..080fd11
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue395/issue395.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-count"((
+    select element l.name
+    from  Employee as l
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.3.query.sqlpp
new file mode 100644
index 0000000..50aedcf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_0/issue412_0.3.query.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.
+ */
+
+"sql-count"(['ASTERIX','Hyracks',null]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.3.query.sqlpp
new file mode 100644
index 0000000..8ffe5f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue412_1/issue412_1.3.query.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.
+ */
+
+{'sql-count':"sql-count"([1,60,null]),'average':"sql-avg"([1,60,null]),'sql-sum':"sql-sum"([1,60,null]),'sql-min':"sql-min"([1,60,null]),'sql-max':"sql-max"([1,60,null])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.3.query.sqlpp
new file mode 100644
index 0000000..1d0f51f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.3.query.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.
+ */
+
+"sql-min"([23,748374857483]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.sqlpp
new file mode 100644
index 0000000..8d6c63a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.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.
+ */
+
+"sql-min"([748374857483,23,0.5]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.sqlpp
new file mode 100644
index 0000000..a05abfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.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.
+ */
+
+"sql-sum"([23,748374857483]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.sqlpp
new file mode 100644
index 0000000..0435afa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.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.
+ */
+
+"sql-sum"([748374857483,23,0.5]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.1.ddl.sqlpp
new file mode 100644
index 0000000..d393206
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/**
+ * issue531_string_sql-min_sql-max
+ *
+ * Purpose: test the support of string values for sql-min and sql-max aggregation function
+ * Result: success
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  name : string
+}
+
+create  table t1(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.2.update.sqlpp
new file mode 100644
index 0000000..ed53f85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.2.update.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/**
+ * issue531_string_sql-min_sql-max
+ * 
+ * Purpose: test the support of string values for sql-min and sql-max aggregation function
+ * Result: success
+ * 
+ */
+
+use test;
+
+
+insert into t1
+select element {'id':5,'name':'Smith'};
+insert into t1
+select element {'id':12,'name':'Roger'};
+insert into t1
+select element {'id':67,'name':'Kevin'};
+insert into t1
+select element {'id':32,'name':'Bob'};
+insert into t1
+select element {'id':89,'name':'John'};
+insert into t1
+select element {'id':10,'name':'Alex'};
+insert into t1
+select element {'id':37,'name':'Calvin'};
+insert into t1
+select element {'id':98,'name':'Susan'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.3.query.sqlpp
new file mode 100644
index 0000000..da72ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/**
+ * issue531_string_sql-min_sql-max
+ * 
+ * Purpose: test the support of string values for sql-min and sql-max aggregation function
+ * Result: success
+ * 
+ */
+
+use test;
+
+
+select element {'sql-min':test."sql-min"((
+        select element l.name
+        from  t1 as l
+    )),'sql-max':test."sql-max"((
+        select element l.name
+        from  t1 as l
+    ))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..d497b33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that sql-max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..7ed3258
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..a11559d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_01/max_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that sql-max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-max"((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..98ceb13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that sql-max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..2599da6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..0d1bd13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/max_empty_02/max_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-max"((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..8574115d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that sql-min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..0313677
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..d02d66e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_01/min_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that sql-min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-min"((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..7ff9d0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that sql-min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..2c8ed44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..965dd90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_empty_02/min_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-min"((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..21781b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.1.ddl.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.
+ */
+/*
+* Description  : Run sql-min over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.3.query.sqlpp
new file mode 100644
index 0000000..f4b95b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/min_mixed/min_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run sql-min over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
+select element "sql-min"((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.3.query.sqlpp
new file mode 100644
index 0000000..20056ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/query-issue400/query-issue400.3.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue400
+
+"sql-count"(select element i
+from  [[1,2,3,4,5],[6,7,8,9]] as i
+);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.1.ddl.sqlpp
new file mode 100644
index 0000000..e81a84a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.2.update.sqlpp
new file mode 100644
index 0000000..5f90a36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.3.query.sqlpp
new file mode 100644
index 0000000..820e906
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg/scalar_avg.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of sql-avg without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-avg"([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test."sql-avg"([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test."sql-avg"([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test."sql-avg"([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test."sql-avg"([test.float('1'),test.float('2'),test.float('3')]),
+      d as test."sql-avg"([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..9e6913c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.2.update.sqlpp
new file mode 100644
index 0000000..0bcef8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.3.query.sqlpp
new file mode 100644
index 0000000..5b372b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.3.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg with an empty list.
+ * Success        : Yes
+ */
+
+select element "sql-avg"([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.1.ddl.sqlpp
new file mode 100644
index 0000000..1e717cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.2.update.sqlpp
new file mode 100644
index 0000000..5212ef1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-avg with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.3.query.sqlpp
new file mode 100644
index 0000000..325c738
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of sql-avg with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-avg"([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test."sql-avg"([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test."sql-avg"([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test."sql-avg"([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test."sql-avg"([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test."sql-avg"([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.1.ddl.sqlpp
new file mode 100644
index 0000000..1e52a55
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-count without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.2.update.sqlpp
new file mode 100644
index 0000000..2268b81
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-count without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.3.query.sqlpp
new file mode 100644
index 0000000..b6a24fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count/scalar_count.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Tests the scalar version of sql-count without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-count"([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test."sql-count"([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test."sql-count"([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test."sql-count"([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test."sql-count"([test.float('1'),test.float('2'),test.float('3')]),
+      d as test."sql-count"([test.double('1'),test.double('2'),test.double('3')]),
+      s as test."sql-count"(['a','b','c'])
+select element i
+from  [i8,i16,i32,i64,f,d,s] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..cefaca4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-count with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.2.update.sqlpp
new file mode 100644
index 0000000..ba1e7ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-count with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.3.query.sqlpp
new file mode 100644
index 0000000..5d37bc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of sql-count with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-count"([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.1.ddl.sqlpp
new file mode 100644
index 0000000..2185f6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-count with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.2.update.sqlpp
new file mode 100644
index 0000000..d707601
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-count with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.3.query.sqlpp
new file mode 100644
index 0000000..c0500e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Tests the scalar version of sql-count with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-count"([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test."sql-count"([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test."sql-count"([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test."sql-count"([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test."sql-count"([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test."sql-count"([test.double('1'),test.double('2'),test.double('3'),null]),
+      s as test."sql-count"(['a','b','c',null])
+select element i
+from  [i8,i16,i32,i64,f,d,s] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.1.ddl.sqlpp
new file mode 100644
index 0000000..d95f53b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-max without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.2.update.sqlpp
new file mode 100644
index 0000000..2e50374
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-max without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.3.query.sqlpp
new file mode 100644
index 0000000..ca96275
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max/scalar_max.3.query.sqlpp
@@ -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    : Tests the scalar version of sql-max without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-max"([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test."sql-max"([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test."sql-max"([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test."sql-max"([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test."sql-max"([test.float('1'),test.float('2'),test.float('3')]),
+      d as test."sql-max"([test.double('1'),test.double('2'),test.double('3')]),
+      s as test."sql-max"(['foo','bar','world']),
+      dt as test."sql-max"([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z')])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..1c9bfdd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-max with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.2.update.sqlpp
new file mode 100644
index 0000000..f4e1750
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-max with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.3.query.sqlpp
new file mode 100644
index 0000000..3535f66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of sql-max with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-max"([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.1.ddl.sqlpp
new file mode 100644
index 0000000..2673223
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-max with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.2.update.sqlpp
new file mode 100644
index 0000000..a0de2d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-max with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.3.query.sqlpp
new file mode 100644
index 0000000..813307a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.3.query.sqlpp
@@ -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    : Tests the scalar version of sql-max with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-max"([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test."sql-max"([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test."sql-max"([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test."sql-max"([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test."sql-max"([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test."sql-max"([test.double('1'),test.double('2'),test.double('3'),null]),
+      s as test."sql-max"(['foo','bar','world',null]),
+      dt as test."sql-max"([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z'),null])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.1.ddl.sqlpp
new file mode 100644
index 0000000..7fec35a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-min without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.2.update.sqlpp
new file mode 100644
index 0000000..b7f1259
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-min without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.3.query.sqlpp
new file mode 100644
index 0000000..eb52dad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min/scalar_min.3.query.sqlpp
@@ -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    : Tests the scalar version of sql-min without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-min"([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test."sql-min"([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test."sql-min"([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test."sql-min"([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test."sql-min"([test.float('1'),test.float('2'),test.float('3')]),
+      d as test."sql-min"([test.double('1'),test.double('2'),test.double('3')]),
+      s as test."sql-min"(['foo','bar','world']),
+      dt as test."sql-min"([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z')])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..f473284
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-min with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.2.update.sqlpp
new file mode 100644
index 0000000..bf0e2ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-min with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.3.query.sqlpp
new file mode 100644
index 0000000..fb1ca8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of sql-min with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-min"([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.1.ddl.sqlpp
new file mode 100644
index 0000000..e2059e6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-min with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.2.update.sqlpp
new file mode 100644
index 0000000..4fc7710
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-min with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.3.query.sqlpp
new file mode 100644
index 0000000..290a1c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.3.query.sqlpp
@@ -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    : Tests the scalar version of sql-min with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-min"([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test."sql-min"([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test."sql-min"([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test."sql-min"([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test."sql-min"([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test."sql-min"([test.double('1'),test.double('2'),test.double('3'),null]),
+      s as test."sql-min"(['foo','bar','world',null]),
+      dt as test."sql-min"([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z'),null])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.1.ddl.sqlpp
new file mode 100644
index 0000000..d6aa2ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-sum without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.2.update.sqlpp
new file mode 100644
index 0000000..dc9de50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-sum without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.3.query.sqlpp
new file mode 100644
index 0000000..9f799ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum/scalar_sum.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of sql-sum without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-sum"([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test."sql-sum"([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test."sql-sum"([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test."sql-sum"([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test."sql-sum"([test.float('1'),test.float('2'),test.float('3')]),
+      d as test."sql-sum"([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..4a58f94
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-sum with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.2.update.sqlpp
new file mode 100644
index 0000000..cbf8790
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-sum with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.3.query.sqlpp
new file mode 100644
index 0000000..b101b78
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of sql-sum with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-sum"([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.1.ddl.sqlpp
new file mode 100644
index 0000000..a7d4b35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-sum with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.2.update.sqlpp
new file mode 100644
index 0000000..980a38e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sql-sum with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.3.query.sqlpp
new file mode 100644
index 0000000..4bd7894
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of sql-sum with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test."sql-sum"([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test."sql-sum"([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test."sql-sum"([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test."sql-sum"([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test."sql-sum"([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test."sql-sum"([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.3.query.sqlpp
new file mode 100644
index 0000000..6bb46d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double/sum_double.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [1.0,2.0,3.0] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.3.query.sqlpp
new file mode 100644
index 0000000..30945ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_double_null/sum_double_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.doubleField
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..5559c89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that sql-sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..7f09a49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..b20de6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that sql-sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..6316d09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that sql-sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int64,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..f19da12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that sql-sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..737f23f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sql-sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.3.query.sqlpp
new file mode 100644
index 0000000..f84c73b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float/sum_float.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.3.query.sqlpp
new file mode 100644
index 0000000..367f251
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_float_null/sum_float_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.floatField
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.3.query.sqlpp
new file mode 100644
index 0000000..317daf0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16/sum_int16.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [test.int16('1'),test.int16('2'),test.int16('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..6f269f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.int16Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.3.query.sqlpp
new file mode 100644
index 0000000..7f85f31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32/sum_int32.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [test.int32('1'),test.int32('2'),test.int32('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..8339998
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.int32Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.3.query.sqlpp
new file mode 100644
index 0000000..57afbfc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64/sum_int64.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [test.int64('1'),test.int64('2'),test.int64('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..c555e24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.int64Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.3.query.sqlpp
new file mode 100644
index 0000000..046bdd0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8/sum_int8.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x
+    from  [test.int8('1'),test.int8('2'),test.int8('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..78b048b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..d2414d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element x.int8Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..24bdd1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.1.ddl.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.
+ */
+/*
+* Description  : Run sql-sum over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp
new file mode 100644
index 0000000..d05df5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run sql-sum over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Feb 7th 2014
+*/
+
+select element "sql-sum"((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.1.ddl.sqlpp
new file mode 100644
index 0000000..3442fd4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.1.ddl.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.
+ */
+/*
+ * Description      :   sql-sum() aggregate function must return the numeric sql-sum, when non null values are given as input to sql-sum().
+ *                  :   Get the sql-sum for those tuples which are non null for salary fields.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  sal : int64?
+}
+
+create  table tdst(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.2.update.sqlpp
new file mode 100644
index 0000000..5d723c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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      :   sql-sum() aggregate function must return the numeric sql-sum, when non null values are given as input to sql-sum().
+ *                  :   Get the sql-sum for those tuples which are non null for salary fields.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+insert into tdst
+select element {'id':123,'sal':1000};
+insert into tdst
+select element {'id':113,'sal':2000};
+insert into tdst
+select element {'id':163,'sal':3000};
+insert into tdst
+select element {'id':161,'sal':4000};
+insert into tdst
+select element {'id':173,'sal':5000};
+insert into tdst
+select element {'id':183,'sal':null};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.3.query.sqlpp
new file mode 100644
index 0000000..6f538cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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      :   sql-sum() aggregate function must return the numeric sql-sum, when non null values are given as input to sql-sum().
+ *                  :   Get the sql-sum for those tuples which are non null for salary fields.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element test."sql-sum"((
+    select element l.sal
+    from  tdst as l
+    where test.not(test."is-null"(l.sal))
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.1.ddl.sqlpp
new file mode 100644
index 0000000..942e2a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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      :   Add numeric values with a null value, sql-sum() aggregate function must return null.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  sal : int64?
+}
+
+create  table tdst(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.2.update.sqlpp
new file mode 100644
index 0000000..44cc106
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.2.update.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.
+ */
+/*
+ * Description      :   Add numeric values with a null value, sql-sum() aggregate function must return null.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+insert into tdst
+select element {'id':123,'sal':1000};
+insert into tdst
+select element {'id':113,'sal':2000};
+insert into tdst
+select element {'id':163,'sal':3000};
+insert into tdst
+select element {'id':161,'sal':4000};
+insert into tdst
+select element {'id':173,'sal':5000};
+insert into tdst
+select element {'id':183,'sal':null};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.3.query.sqlpp
new file mode 100644
index 0000000..ed82deb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :   Add numeric values with a null value, sql-sum() aggregate function must return null.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+select element test."sql-sum"((
+    select element l.sal
+    from  tdst as l
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.1.ddl.sqlpp
new file mode 100644
index 0000000..dff0caf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.1.ddl.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.
+ */
+/*
+* Description  : Run aggregates over both ordered list and unordered list with only null items.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.sqlpp
new file mode 100644
index 0000000..dc3ef07
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null/agg_null.3.query.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.
+ */
+/*
+* Description  : Run aggregates over both ordered list and unordered list with only null items.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+{'count1':count([null]),'average1':avg([null]),'sum1':sum([null]),'min1':min([null]),'max1':max([null]),'count2':count({{null,null}}),'average2':avg({{null,null}}),'sum2':sum({{null,null}}),'min2':min({{null,null}}),'max2':max({{null,null}})};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.1.ddl.sqlpp
new file mode 100644
index 0000000..a09654e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.2.update.sqlpp
new file mode 100644
index 0000000..5abf639
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.2.update.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.
+ */
+/*
+* Description  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+use test;
+
+
+insert into Test
+select element {'id':0,'val':4.32,'valplus':473847};
+insert into Test
+select element {'id':1,'val':5.32};
+insert into Test
+select element {'id':2,'val':6.32,'valplus':38473827484738239};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp
new file mode 100644
index 0000000..ddd882e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+use test;
+
+
+{'count':test.count((
+    select element t.valplus
+    from  Test as t
+)),'average':test.avg((
+    select element t.valplus
+    from  Test as t
+)),'sum':test.sum((
+    select element t.valplus
+    from  Test as t
+)),'min':test.min((
+    select element t.valplus
+    from  Test as t
+)),'max':test.max((
+    select element t.valplus
+    from  Test as t
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.1.ddl.sqlpp
new file mode 100644
index 0000000..a09654e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.2.update.sqlpp
new file mode 100644
index 0000000..5abf639
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.2.update.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.
+ */
+/*
+* Description  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+use test;
+
+
+insert into Test
+select element {'id':0,'val':4.32,'valplus':473847};
+insert into Test
+select element {'id':1,'val':5.32};
+insert into Test
+select element {'id':2,'val':6.32,'valplus':38473827484738239};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
new file mode 100644
index 0000000..6cf606d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+use test;
+
+
+{'count':test.count((
+    select element t
+    from  Test as t
+)),'average':test.avg((
+    select element i.val
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'sum':test.sum((
+    select element i.val
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'min':test.min((
+    select element i.valplus
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+)),'max':test.max((
+    select element i.valplus
+    from  (
+        select element t
+        from  Test as t
+    ) as i
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.1.ddl.sqlpp
new file mode 100644
index 0000000..878fdb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.1.ddl.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.
+ */
+/*
+* Description  : Run aggregates over an ordered list with numbers of different types
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.sqlpp
new file mode 100644
index 0000000..87f159f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number/agg_number.3.query.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.
+ */
+/*
+* Description  : Run aggregates over an ordered list with numbers of different types
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+{'count1':count([float('2.0'),double('3.0'),93847382783847382,1]),'average1':avg([float('2.0'),double('3.0'),93847382783847382,1]),'sum1':sum([float('2.0'),double('3.0'),93847382783847382,1]),'min1':min([float('2.0'),double('3.0'),93847382783847382,1]),'max1':max([float('2.0'),double('3.0'),93847382783847382,1]),'count2':count({{float('2.0'),double('3.0'),93847382783847382,1}}),'average2':avg({{float('2.0'),double('3.0'),93847382783847382,1}}),'sum2':sum({{float('2.0'),double('3.0'),93847382783847382,1}}),'min2':min({{float('2.0'),double('3.0'),93847382783847382,1}}),'max2':max({{float('2.0'),double('3.0'),93847382783847382,1}})};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.1.ddl.sqlpp
new file mode 100644
index 0000000..47eec34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.2.update.sqlpp
new file mode 100644
index 0000000..03144bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.2.update.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.
+ */
+/*
+* Description  : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+use test;
+
+
+insert into Test
+select element {'id':0,'val':4.32,'valplus':2};
+insert into Test
+select element {'id':1,'val':5.32,'valplus':32.98};
+insert into Test
+select element {'id':2,'val':6.32,'valplus':38473827484738239};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp
new file mode 100644
index 0000000..63ba0ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date         : Jun 2nd 2013
+*/
+
+use test;
+
+
+{'count':test.count((
+    select element t.valplus
+    from  Test as t
+)),'average':test.avg((
+    select element t.valplus
+    from  Test as t
+)),'sum':test.sum((
+    select element t.valplus
+    from  Test as t
+)),'min':test.min((
+    select element t.valplus
+    from  Test as t
+)),'max':test.max((
+    select element t.valplus
+    from  Test as t
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.3.query.sqlpp
new file mode 100644
index 0000000..12a1cfb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double/avg_double.3.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.
+ */
+
+select element avg((
+    select element x
+    from  [1.0,2.0,double('3.0')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.3.query.sqlpp
new file mode 100644
index 0000000..2926232
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_double_null/avg_double_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test.avg((
+    select element x.doubleField
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..ba32a30
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..cf6e09b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..10aa600
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_01/avg_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..08764fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..1d898e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..7b6a34a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_empty_02/avg_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that avg aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.3.query.sqlpp
new file mode 100644
index 0000000..264ec2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float/avg_float.3.query.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.
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.3.query.sqlpp
new file mode 100644
index 0000000..bbc0d48
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_float_null/avg_float_nu.3.query.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.
+ */
+
+use test;
+
+
+{'average':test.avg((
+    select element x.floatField
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.3.query.sqlpp
new file mode 100644
index 0000000..d370467
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16/avg_int16.3.query.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.
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x
+    from  [test.int16('1'),test.int16('2'),test.int16('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..2587a9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int16_null/avg_int16_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test.avg((
+    select element x.int16Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.3.query.sqlpp
new file mode 100644
index 0000000..769f3d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32/avg_int32.3.query.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.
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x
+    from  [1,2,3] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..acb814e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int32_null/avg_int32_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test.avg((
+    select element x.int32Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.3.query.sqlpp
new file mode 100644
index 0000000..1734f7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64/avg_int64.3.query.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.
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x
+    from  [test.int64('1'),test.int64('2'),test.int64('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..b320332
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int64_null/avg_int64_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test.avg((
+    select element x.int64Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.3.query.sqlpp
new file mode 100644
index 0000000..f2b9ac6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8/avg_int8.3.query.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.
+ */
+
+use test;
+
+
+select element test.avg((
+    select element x
+    from  [test.int8('1'),test.int8('2'),test.int8('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..1753b77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_int8_null/avg_int8_null.3.query.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.
+ */
+
+use test;
+
+
+{'average':test.avg((
+    select element x.int8Field
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..095f14e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.1.ddl.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.
+ */
+/*
+* Description  : Run avg over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp
new file mode 100644
index 0000000..988020f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/avg_mixed/avg_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run avg over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
+select element avg((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.3.query.sqlpp
new file mode 100644
index 0000000..5c81a50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_01/count_01.3.query.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.
+ */
+
+use test;
+
+
+select element test.count((
+    select element x
+    from  [1,2,3] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..37e0f78
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.1.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..0f1d907
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..4be4da7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_01/count_empty_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+select element count((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..5b35246
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..01ace29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..c36e99a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_empty_02/count_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that count aggregation correctly returns 0 for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.count((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.3.query.sqlpp
new file mode 100644
index 0000000..5d60f10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/count_null/count_null.3.query.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.
+ */
+
+use test;
+
+
+{'count':test.count((
+    select element x.doubleField
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.1.ddl.sqlpp
new file mode 100644
index 0000000..4ae5862
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test to cover =>  create type - drop type - recreate that dropped type 
+ * Expected Res : Success
+ * Date         : 13 Sep 2012
+ * Issue        : 188
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.footype as
+{
+  bar : int32?
+}
+
+drop type test.footype;
+create type test.footype as
+{
+  bar : int32?
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.2.update.sqlpp
new file mode 100644
index 0000000..8b86c56
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.2.update.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.
+ */
+/*
+ * Description  : Test to cover =>  create type - drop type - recreate that dropped type 
+ * Expected Res : Success
+ * Date         : 13 Sep 2012
+ * Issue        : 188
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.3.query.sqlpp
new file mode 100644
index 0000000..8b86c56
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/droptype/droptype.3.query.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.
+ */
+/*
+ * Description  : Test to cover =>  create type - drop type - recreate that dropped type 
+ * Expected Res : Success
+ * Date         : 13 Sep 2012
+ * Issue        : 188
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.3.query.sqlpp
new file mode 100644
index 0000000..6dc0ab3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_01/global-avg_01.3.query.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.
+ */
+
+use test;
+
+
+select element test."global-avg"((
+    select element {'sum':x,'count':1}
+    from  [1.0,2.0,test.double('3.0')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.3.query.sqlpp
new file mode 100644
index 0000000..b54d99a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/global-avg_null/global-avg_null.3.query.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.
+ */
+
+use test;
+
+
+{'global-average':test."global-avg"((
+    select element {'sum':x.doubleField,'count':x.int32Field}
+    from  Numeric as x
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.1.ddl.sqlpp
new file mode 100644
index 0000000..b66178f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+{
+  id : int32,
+  name : string?
+}
+
+create  table Employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.2.update.sqlpp
new file mode 100644
index 0000000..59fbfb3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.2.update.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.
+ */
+
+use test;
+
+
+insert into Employee
+select element {'id':12,'name':'John Doe'};
+insert into Employee
+select element {'id':42};
+insert into Employee
+select element {'id':22,'name':'John Smith'};
+insert into Employee
+select element {'id':19};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.3.query.sqlpp
new file mode 100644
index 0000000..81aa828
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue395/issue395.3.query.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.
+ */
+
+use test;
+
+
+select element test.count((
+    select element l.name
+    from  Employee as l
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.3.query.sqlpp
new file mode 100644
index 0000000..5dcf622
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_0/issue412_0.3.query.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.
+ */
+
+count(['ASTERIX','Hyracks',null]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.3.query.sqlpp
new file mode 100644
index 0000000..78c9164
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue412_1/issue412_1.3.query.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.
+ */
+
+{'count':count([1,60,null]),'average':avg([1,60,null]),'sum':sum([1,60,null]),'min':min([1,60,null]),'max':max([1,60,null])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.query.sqlpp
new file mode 100644
index 0000000..40631ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.query.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.
+ */
+
+min([23,748374857483]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.sqlpp
new file mode 100644
index 0000000..8d438e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.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.
+ */
+
+min([748374857483,23,0.5]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.sqlpp
new file mode 100644
index 0000000..17fd1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.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.
+ */
+
+sum([23,748374857483]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.sqlpp
new file mode 100644
index 0000000..41429b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.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.
+ */
+
+sum([748374857483,23,0.5]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.sqlpp
new file mode 100644
index 0000000..a99a633
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/**
+ * issue531_string_min_max
+ * 
+ * Purpose: test the support of string values for min and max aggregation function
+ * Result: success
+ * 
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  name : string
+}
+
+create  table t1(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.sqlpp
new file mode 100644
index 0000000..6ee731d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/**
+ * issue531_string_min_max
+ * 
+ * Purpose: test the support of string values for min and max aggregation function
+ * Result: success
+ * 
+ */
+
+use test;
+
+
+insert into t1
+select element {'id':5,'name':'Smith'};
+insert into t1
+select element {'id':12,'name':'Roger'};
+insert into t1
+select element {'id':67,'name':'Kevin'};
+insert into t1
+select element {'id':32,'name':'Bob'};
+insert into t1
+select element {'id':89,'name':'John'};
+insert into t1
+select element {'id':10,'name':'Alex'};
+insert into t1
+select element {'id':37,'name':'Calvin'};
+insert into t1
+select element {'id':98,'name':'Susan'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.sqlpp
new file mode 100644
index 0000000..aaec7a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/**
+ * issue531_string_min_max
+ * 
+ * Purpose: test the support of string values for min and max aggregation function
+ * Result: success
+ * 
+ */
+
+use test;
+
+
+select element {'min':test.min((
+        select element l.name
+        from  t1 as l
+    )),'max':test.max((
+        select element l.name
+        from  t1 as l
+    ))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.3.query.sqlpp
new file mode 100644
index 0000000..1972073
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double/local-avg_double.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [1.0,2.0,test.double('3.0')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.3.query.sqlpp
new file mode 100644
index 0000000..37a86a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_double_null/local-avg_double_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x.doubleField
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.3.query.sqlpp
new file mode 100644
index 0000000..8cd133b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float/local-avg_float.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.3.query.sqlpp
new file mode 100644
index 0000000..da8d863
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_float_null/local-avg_float_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x.floatField
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..0446579
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [test.int16('1'),test.int16('2'),test.int16('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.3.query.sqlpp
new file mode 100644
index 0000000..e539873
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16/local-avg_int16.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [test.int16('1'),test.int16('2'),test.int16('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..fd58477
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int16_null/local-avg_int16_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x.int16Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.3.query.sqlpp
new file mode 100644
index 0000000..f0ecff5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32/local-avg_int32.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [1,2,3] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..ac472c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int32_null/local-avg_int32_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x.int32Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.3.query.sqlpp
new file mode 100644
index 0000000..c3e89cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64/local-avg_int64.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [test.int64('1'),test.int64('2'),test.int64('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..8ee14dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int64_null/local-avg_int64_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x.int64Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.3.query.sqlpp
new file mode 100644
index 0000000..2f6d401
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8/local-avg_int8.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x
+    from  [test.int8('1'),test.int8('2'),test.int8('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..96088b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/local-avg_int8_null/local-avg_int8_null.3.query.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.
+ */
+
+use test;
+
+
+select element test."local-avg"((
+    select element x.int8Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..d43c695
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..d74ada7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..8d565eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_01/max_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.max((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..f4049e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..b22f630
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..442f496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/max_empty_02/max_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that max aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.max((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4e087df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..47e5497
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..d476fcf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_01/min_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.min((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..12d435b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..35e8c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..ad14ddd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_empty_02/min_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that min aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.min((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..45af77f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.1.ddl.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.
+ */
+/*
+* Description  : Run min over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.3.query.sqlpp
new file mode 100644
index 0000000..0b5dced
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/min_mixed/min_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run min over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
+select element min((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.3.query.sqlpp
new file mode 100644
index 0000000..a701efd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/query-issue400/query-issue400.3.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue400
+
+count(select element i
+from  [[1,2,3,4,5],[6,7,8,9]] as i
+);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.1.ddl.sqlpp
new file mode 100644
index 0000000..535888f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.2.update.sqlpp
new file mode 100644
index 0000000..35ffb43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.3.query.sqlpp
new file mode 100644
index 0000000..8312274
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg/scalar_avg.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of avg without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.avg([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test.avg([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test.avg([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test.avg([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test.avg([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.avg([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..efb58fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.2.update.sqlpp
new file mode 100644
index 0000000..b37c0d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.3.query.sqlpp
new file mode 100644
index 0000000..39344f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.3.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg with an empty list.
+ * Success        : Yes
+ */
+
+select element avg([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.1.ddl.sqlpp
new file mode 100644
index 0000000..b0c0da9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.2.update.sqlpp
new file mode 100644
index 0000000..7265234
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of avg with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.3.query.sqlpp
new file mode 100644
index 0000000..2e0293f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of avg with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.avg([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test.avg([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test.avg([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test.avg([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test.avg([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.avg([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.1.ddl.sqlpp
new file mode 100644
index 0000000..a36f9ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of count without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.2.update.sqlpp
new file mode 100644
index 0000000..411b984
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of count without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.3.query.sqlpp
new file mode 100644
index 0000000..bcaad9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count/scalar_count.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Tests the scalar version of count without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.count([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test.count([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test.count([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test.count([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test.count([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.count([test.double('1'),test.double('2'),test.double('3')]),
+      s as test.count(['a','b','c'])
+select element i
+from  [i8,i16,i32,i64,f,d,s] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..e32d56e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of count with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.2.update.sqlpp
new file mode 100644
index 0000000..010d5ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of count with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.3.query.sqlpp
new file mode 100644
index 0000000..ce9798d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of count with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.count([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.1.ddl.sqlpp
new file mode 100644
index 0000000..0c3e5ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of count with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.2.update.sqlpp
new file mode 100644
index 0000000..b4776d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of count with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.3.query.sqlpp
new file mode 100644
index 0000000..8cb1e66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_count_null/scalar_count_null.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Tests the scalar version of count with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.count([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test.count([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test.count([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test.count([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test.count([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.count([test.double('1'),test.double('2'),test.double('3'),null]),
+      s as test.count(['a','b','c',null])
+select element i
+from  [i8,i16,i32,i64,f,d,s] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.1.ddl.sqlpp
new file mode 100644
index 0000000..938f3a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of max without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.2.update.sqlpp
new file mode 100644
index 0000000..5d66640
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of max without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.3.query.sqlpp
new file mode 100644
index 0000000..0070b55
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max/scalar_max.3.query.sqlpp
@@ -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    : Tests the scalar version of max without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.max([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test.max([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test.max([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test.max([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test.max([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.max([test.double('1'),test.double('2'),test.double('3')]),
+      s as test.max(['foo','bar','world']),
+      dt as test.max([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z')])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..4bb7891
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of max with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.2.update.sqlpp
new file mode 100644
index 0000000..b2dee7c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of max with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.3.query.sqlpp
new file mode 100644
index 0000000..3bbf7e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of max with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.max([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.1.ddl.sqlpp
new file mode 100644
index 0000000..2202f10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of max with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.2.update.sqlpp
new file mode 100644
index 0000000..b3d8013
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of max with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.3.query.sqlpp
new file mode 100644
index 0000000..bccf473
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_max_null/scalar_max_null.3.query.sqlpp
@@ -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    : Tests the scalar version of max with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.max([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test.max([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test.max([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test.max([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test.max([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.max([test.double('1'),test.double('2'),test.double('3'),null]),
+      s as test.max(['foo','bar','world',null]),
+      dt as test.max([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z'),null])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.1.ddl.sqlpp
new file mode 100644
index 0000000..966c773
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of min without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.2.update.sqlpp
new file mode 100644
index 0000000..b4f3832
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of min without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.3.query.sqlpp
new file mode 100644
index 0000000..89e07a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min/scalar_min.3.query.sqlpp
@@ -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    : Tests the scalar version of min without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.min([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test.min([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test.min([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test.min([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test.min([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.min([test.double('1'),test.double('2'),test.double('3')]),
+      s as test.min(['foo','bar','world']),
+      dt as test.min([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z')])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..0938588
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of min with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.2.update.sqlpp
new file mode 100644
index 0000000..3e6cb25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of min with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.3.query.sqlpp
new file mode 100644
index 0000000..2d1db86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of min with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.min([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.1.ddl.sqlpp
new file mode 100644
index 0000000..5ba5007
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of min with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.2.update.sqlpp
new file mode 100644
index 0000000..a94d8d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of min with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.3.query.sqlpp
new file mode 100644
index 0000000..71d04ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_min_null/scalar_min_null.3.query.sqlpp
@@ -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    : Tests the scalar version of min with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.min([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test.min([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test.min([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test.min([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test.min([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.min([test.double('1'),test.double('2'),test.double('3'),null]),
+      s as test.min(['foo','bar','world',null]),
+      dt as test.min([test.datetime('2012-03-01T00:00:00Z'),test.datetime('2012-01-01T00:00:00Z'),test.datetime('2012-02-01T00:00:00Z'),null])
+select element i
+from  [i8,i16,i32,i64,f,d,s,dt] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.1.ddl.sqlpp
new file mode 100644
index 0000000..3a57b3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sum without nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.2.update.sqlpp
new file mode 100644
index 0000000..e685823
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sum without nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.3.query.sqlpp
new file mode 100644
index 0000000..08a1049
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum/scalar_sum.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of sum without nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.sum([test.int8('1'),test.int8('2'),test.int8('3')]),
+      i16 as test.sum([test.int16('1'),test.int16('2'),test.int16('3')]),
+      i32 as test.sum([test.int32('1'),test.int32('2'),test.int32('3')]),
+      i64 as test.sum([test.int64('1'),test.int64('2'),test.int64('3')]),
+      f as test.sum([test.float('1'),test.float('2'),test.float('3')]),
+      d as test.sum([test.double('1'),test.double('2'),test.double('3')])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.1.ddl.sqlpp
new file mode 100644
index 0000000..d58b199
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sum with an empty list.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.2.update.sqlpp
new file mode 100644
index 0000000..6efe5ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sum with an empty list.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.3.query.sqlpp
new file mode 100644
index 0000000..8bd634e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests the scalar version of sum with an empty list.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.sum([]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.1.ddl.sqlpp
new file mode 100644
index 0000000..08dc0d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.1.ddl.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.
+ */
+/*
+ * Description    : Tests the scalar version of sum with nulls.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.2.update.sqlpp
new file mode 100644
index 0000000..40673ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.2.update.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.
+ */
+/*
+ * Description    : Tests the scalar version of sum with nulls.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.3.query.sqlpp
new file mode 100644
index 0000000..04ecae3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Tests the scalar version of sum with nulls.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  i8 as test.sum([test.int8('1'),test.int8('2'),test.int8('3'),null]),
+      i16 as test.sum([test.int16('1'),test.int16('2'),test.int16('3'),null]),
+      i32 as test.sum([test.int32('1'),test.int32('2'),test.int32('3'),null]),
+      i64 as test.sum([test.int64('1'),test.int64('2'),test.int64('3'),null]),
+      f as test.sum([test.float('1'),test.float('2'),test.float('3'),null]),
+      d as test.sum([test.double('1'),test.double('2'),test.double('3'),null])
+select element i
+from  [i8,i16,i32,i64,f,d] as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.3.query.sqlpp
new file mode 100644
index 0000000..bd7092e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double/sum_double.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [1.0,2.0,3.0] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.3.query.sqlpp
new file mode 100644
index 0000000..ed194cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_double_null/sum_double_null.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.doubleField
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.1.ddl.sqlpp
new file mode 100644
index 0000000..3b32932
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.2.update.sqlpp
new file mode 100644
index 0000000..1bd16cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.2.update.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.
+ */
+/*
+ * Description    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.3.query.sqlpp
new file mode 100644
index 0000000..a3cab15
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_01/sum_empty_01.3.query.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.
+ */
+/*
+ * Description    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  without an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [1,2,3] as x
+    where (x > 10)
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.1.ddl.sqlpp
new file mode 100644
index 0000000..10e1274
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  val : double
+}
+
+create  table Test(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.2.update.sqlpp
new file mode 100644
index 0000000..02b7327
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.2.update.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.
+ */
+/*
+ * Description    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.3.query.sqlpp
new file mode 100644
index 0000000..181ff0d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_empty_02/sum_empty_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests that sum aggregation correctly returns null for an empty stream,
+ *                  with an aggregate combiner.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.val
+    from  Test as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.3.query.sqlpp
new file mode 100644
index 0000000..a9bceb8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float/sum_float.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [test.float('1'),test.float('2'),test.float('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.3.query.sqlpp
new file mode 100644
index 0000000..30ef69c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_float_null/sum_float_null.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.floatField
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.3.query.sqlpp
new file mode 100644
index 0000000..7f8b538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16/sum_int16.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [test.int16('1'),test.int16('2'),test.int16('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.3.query.sqlpp
new file mode 100644
index 0000000..7b86f76
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int16_null/sum_int16_null.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.int16Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.3.query.sqlpp
new file mode 100644
index 0000000..9c136e2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32/sum_int32.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [test.int32('1'),test.int32('2'),test.int32('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.3.query.sqlpp
new file mode 100644
index 0000000..61984d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int32_null/sum_int32_null.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.int32Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.3.query.sqlpp
new file mode 100644
index 0000000..d35ab0f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64/sum_int64.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [test.int64('1'),test.int64('2'),test.int64('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.3.query.sqlpp
new file mode 100644
index 0000000..189e9f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int64_null/sum_int64_null.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.int64Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.3.query.sqlpp
new file mode 100644
index 0000000..536a03f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8/sum_int8.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x
+    from  [test.int8('1'),test.int8('2'),test.int8('3')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc50de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int32,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.3.query.sqlpp
new file mode 100644
index 0000000..98922f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_int8_null/sum_int8_null.3.query.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.
+ */
+
+use test;
+
+
+select element test.sum((
+    select element x.int8Field
+    from  Numeric as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..cf91051
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.1.ddl.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.
+ */
+/*
+* Description  : Run sum over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp
new file mode 100644
index 0000000..f4e1265
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_mixed/sum_mixed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Run sum over an ordered list with mixed types
+* Expected Res : Failure
+* Date         : Jun 2nd 2013
+*/
+
+select element sum((
+    select element x
+    from  [float('2.0'),'hello world',93847382783847382,date('2013-01-01')] as x
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.1.ddl.sqlpp
new file mode 100644
index 0000000..2405389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.1.ddl.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.
+ */
+/*
+ * Description      :   sum() aggregate function must return the numeric sum, when non null values are given as input to sum().
+ *                  :   Get the sum for those tuples which are non null for salary fields.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64,
+  sal : int64?
+}
+
+create  table tdst(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.2.update.sqlpp
new file mode 100644
index 0000000..a3ac94f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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      :   sum() aggregate function must return the numeric sum, when non null values are given as input to sum().
+ *                  :   Get the sum for those tuples which are non null for salary fields.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+insert into tdst
+select element {'id':123,'sal':1000};
+insert into tdst
+select element {'id':113,'sal':2000};
+insert into tdst
+select element {'id':163,'sal':3000};
+insert into tdst
+select element {'id':161,'sal':4000};
+insert into tdst
+select element {'id':173,'sal':5000};
+insert into tdst
+select element {'id':183,'sal':null};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.sqlpp
new file mode 100644
index 0000000..4734f53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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      :   sum() aggregate function must return the numeric sum, when non null values are given as input to sum().
+ *                  :   Get the sum for those tuples which are non null for salary fields.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element test.sum((
+    select element l.sal
+    from  tdst as l
+    where test.not(test."is-null"(l.sal))
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.1.ddl.sqlpp
new file mode 100644
index 0000000..ed8b33c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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      :   Add numeric values with a null value, sum() aggregate function must return null.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  sal : int32?
+}
+
+create  table tdst(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.2.update.sqlpp
new file mode 100644
index 0000000..7f6846b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.2.update.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.
+ */
+/*
+ * Description      :   Add numeric values with a null value, sum() aggregate function must return null.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+insert into tdst
+select element {'id':123,'sal':345};
+insert into tdst
+select element {'id':113,'sal':335};
+insert into tdst
+select element {'id':163,'sal':315};
+insert into tdst
+select element {'id':161,'sal':365};
+insert into tdst
+select element {'id':173,'sal':385};
+insert into tdst
+select element {'id':183,'sal':null};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.3.query.sqlpp
new file mode 100644
index 0000000..aa3c3da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :   Add numeric values with a null value, sum() aggregate function must return null.
+ * Expected result  :   Success
+ * Date             :   July 20th 2012
+ */
+
+use test;
+
+
+select element test.sum((
+    select element l.sal
+    from  tdst as l
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.1.ddl.sqlpp
new file mode 100644
index 0000000..e193d2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.1.ddl.sqlpp
@@ -0,0 +1,78 @@
+/*
+ * 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  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type test.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create external  table Line(LineType) using "localfs"(("path"="nc1://data/big-object/lineitem.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table "Order"(OrderType) using "localfs"(("path"="nc1://data/big-object/order.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Customer(CustomerType) using "localfs"(("path"="nc1://data/big-object/customer.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.2.update.sqlpp
new file mode 100644
index 0000000..f9506d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.3.query.sqlpp
new file mode 100644
index 0000000..0d596ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby-2/big_object_groupby.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+use test;
+
+
+select element {'id':id,'length':test."string-length"(comment),'comment':comment}
+from  Line as i
+group by i.l_comment as comment,i.l_orderkey as id
+order by id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.1.ddl.sqlpp
new file mode 100644
index 0000000..e193d2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.1.ddl.sqlpp
@@ -0,0 +1,78 @@
+/*
+ * 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  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type test.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create external  table Line(LineType) using "localfs"(("path"="nc1://data/big-object/lineitem.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table "Order"(OrderType) using "localfs"(("path"="nc1://data/big-object/order.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Customer(CustomerType) using "localfs"(("path"="nc1://data/big-object/customer.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.2.update.sqlpp
new file mode 100644
index 0000000..f9506d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.3.query.sqlpp
new file mode 100644
index 0000000..1ed4e28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_groupby/big_object_groupby.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+use test;
+
+
+select element {'partkey':partkey,'lines':i}
+from  Line as i
+group by i.l_partkey as partkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.1.ddl.sqlpp
new file mode 100644
index 0000000..e193d2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.1.ddl.sqlpp
@@ -0,0 +1,78 @@
+/*
+ * 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  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type test.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create external  table Line(LineType) using "localfs"(("path"="nc1://data/big-object/lineitem.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table "Order"(OrderType) using "localfs"(("path"="nc1://data/big-object/order.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Customer(CustomerType) using "localfs"(("path"="nc1://data/big-object/customer.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.2.update.sqlpp
new file mode 100644
index 0000000..f9506d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.3.query.sqlpp
new file mode 100644
index 0000000..972ad80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_join/big_object_join.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+use test;
+
+
+select element {'c_custkey':c.c_custkey,'o_orderkey':o.o_orderkey,'len_c_comment':test."string-length"(c.c_comment),'len_o_comment':test."string-length"(o.o_comment),'c_comment':c.c_comment}
+from  Customer as c,
+      "Order" as o
+where (c.c_custkey = o.o_custkey)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.1.ddl.sqlpp
new file mode 100644
index 0000000..e193d2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.1.ddl.sqlpp
@@ -0,0 +1,78 @@
+/*
+ * 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  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type test.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create external  table Line(LineType) using "localfs"(("path"="nc1://data/big-object/lineitem.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table "Order"(OrderType) using "localfs"(("path"="nc1://data/big-object/order.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Customer(CustomerType) using "localfs"(("path"="nc1://data/big-object/customer.tbl.big"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.2.update.sqlpp
new file mode 100644
index 0000000..f9506d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.3.query.sqlpp
new file mode 100644
index 0000000..8748e7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/big-object/big_object_sort/big_object_sort.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains long comments fields, 10% of the records have a 32K size comments.
+
+use test;
+
+
+select element {'custkey':o.o_custkey,'orderkey':o.o_orderkey,'len-comment':test."string-length"(o.o_comment),'comment':o.o_comment}
+from  "Order" as o
+order by o.o_custkey,o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.3.query.sqlpp
new file mode 100644
index 0000000..ecdcee0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/concat/concat_01.3.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;
+
+
+[(test."binary-concat"([test.hex('aa'),test.hex('259911'),test.hex('bb'),test.hex('31')]) = test.hex('AA259911bb31')),(test."binary-concat"([]) = test.hex('')),test."binary-concat"([null]),test."binary-concat"([null,test.hex('55')]),test."binary-concat"([test.hex('aa'),null]),test."binary-concat"([test.hex('aa'),null,test.base64('asdf')])];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.1.ddl.sqlpp
new file mode 100644
index 0000000..5d0b423
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.UserType as
+ closed {
+  id : int64,
+  name : string,
+  md5 : binary
+}
+
+create  table User(UserType) primary key id;
+
+create  table UserCopy(UserType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.2.update.sqlpp
new file mode 100644
index 0000000..8bb3c73
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.2.update.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.
+ */
+
+use test;
+
+
+load  table User using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/usermd5.adm"),("format"="adm"));
+
+load  table UserCopy using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/usermd5copy.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.3.query.sqlpp
new file mode 100644
index 0000000..8ab5059
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/equal_join/equal_join.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'cid':c.id,'oid':o.id}
+from  User as c,
+      UserCopy as o
+where (c.md5 = o.md5)
+order by c.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.3.query.sqlpp
new file mode 100644
index 0000000..27c5a29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/find/find.3.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;
+
+
+[((test."find-binary"(test.hex('aabbccddaa'),test.hex('')) = 1) and (test."find-binary"(test.hex('aabbccddaa'),test.hex('aa')) = 1) and (test."find-binary"(test.hex('aabbccddaa'),test.hex('aa'),1) = 5) and (test."find-binary"(test.hex('aabbccddaa'),test.hex('aabb'),0) = test."find-binary"(test.hex('aabbccddaa'),test.hex('aabb'))) and (test."find-binary"(test.hex('aabbccddaa'),test.hex('11')) = 0) and (test."find-binary"(test.hex('aabbccddaa'),test.hex('ccddaa')) = 3) and (test."find-binary"(test.hex('aabbccddaa'),test.hex('ccddaabb')) = 0)),test."find-binary"(test.hex('aabbccddaa'),null),test."find-binary"(null,null),test."find-binary"(null,test.hex('aabbccddaa'))];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.1.ddl.sqlpp
new file mode 100644
index 0000000..1946be3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.UserType as
+ closed {
+  id : int64,
+  name : string,
+  md5 : binary
+}
+
+create  table User(UserType) primary key md5;
+
+create  table UserCopy(UserType) primary key md5;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.2.update.sqlpp
new file mode 100644
index 0000000..8bb3c73
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.2.update.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.
+ */
+
+use test;
+
+
+load  table User using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/usermd5.adm"),("format"="adm"));
+
+load  table UserCopy using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/usermd5copy.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.3.query.sqlpp
new file mode 100644
index 0000000..8ab5059
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/index_join/index_join.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'cid':c.id,'oid':o.id}
+from  User as c,
+      UserCopy as o
+where (c.md5 = o.md5)
+order by c.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.1.ddl.sqlpp
new file mode 100644
index 0000000..55ff046
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.UserTypeOpen as
+{
+  id : int64
+}
+
+create type test.UserTypeClose as
+ closed {
+  id : int64,
+  name : string,
+  md5 : binary
+}
+
+create  table UserOpen(UserTypeOpen) primary key id;
+
+create  table UserCopyClose(UserTypeClose) primary key md5;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.2.update.sqlpp
new file mode 100644
index 0000000..d29b3cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+load  table UserOpen using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/usermd5.adm"),("format"="adm"));
+
+load  table UserCopyClose using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/usermd5copy.adm"),("format"="adm"));
+
+insert into UserOpen
+select element {'id':l.id,'name':l.name,'md5':l.md5}
+from  UserCopyClose as l
+where (l.id > 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.3.query.sqlpp
new file mode 100644
index 0000000..3c949ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/insert/insert.3.query.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.
+ */
+
+use test;
+
+
+select element c
+from  UserOpen as c
+order by c.id,c.md5
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.3.query.sqlpp
new file mode 100644
index 0000000..70e77d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/length/length.3.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;
+
+
+{'result1':test."binary-length"(test.hex('00AA')),'result2':test."binary-length"(test.hex('')),'result3':test."binary-length"(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.3.query.sqlpp
new file mode 100644
index 0000000..4d93abe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/parse/parse.3.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;
+
+
+[test."parse-binary"('ABCDEF0123456789','hex'),test."parse-binary"('abcdef0123456789','HEX'),test."parse-binary"('0A0B0C0D0E0F','hEx'),test."parse-binary"('01020304050607080900','hex'),test."parse-binary"('','hex'),test."parse-binary"('0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM+/','base64'),test."parse-binary"('','base64'),test."parse-binary"('QXN0ZXJpeA==','BASE64'),test."parse-binary"('QXN0ZXJpeAE=','baSE64'),test."parse-binary"('QXN0ZXJpeAE8','base64')];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.3.query.sqlpp
new file mode 100644
index 0000000..21e5b19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/print/print.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+{'hex':(
+    select element (test."print-binary"(test."parse-binary"(i,'hex'),'hex') = i)
+    from  ['ABCDEF0123456789','0A0B0C0D0E0F','01020304050607080900',''] as i
+),'base64':(
+    select element (test."print-binary"(test."parse-binary"(j,'base64'),'base64') = j)
+    from  ['0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM+/','QXN0ZXJpeA==','QXN0ZXJpeAE=','QXN0ZXJpeAE8'] as j
+)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.3.query.sqlpp
new file mode 100644
index 0000000..e47b104
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/binary/subbinary/subbinary_01.3.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;
+
+
+((test."sub-binary"(test.hex(''),0) = test.hex('')) and (test."sub-binary"(test.hex(''),1) = test.hex('')) and (test."sub-binary"(test.hex(''),-1) = test.hex('')) and (test."sub-binary"(test.hex('aabbccdd'),1,test."binary-length"(test.hex('aabbccdd'))) = test.hex('aabbccdd')) and (test."sub-binary"(test.hex('aabbccdd'),2,1) = test.hex('bb')) and (test."sub-binary"(test.hex('aabbccdd'),2) = test.hex('bbccdd')) and (test."sub-binary"(test.hex('aabbccdd'),5,0) = test.hex('')) and (test."sub-binary"(test.hex('aabbccdd'),4,1) = test.hex('dd')) and (test."sub-binary"(test.hex('aabbccdd'),2,2) = test.hex('bbcc')) and (test."sub-binary"(test.hex('aabbccdd'),0) = test.hex('aabbccdd')) and (test."sub-binary"(test.hex('aabbccdd'),-1) = test.hex('aabbccdd')) and (test."sub-binary"(test.hex('aabbccdd'),1,256) = test.hex('aabbccdd')) and (test."sub-binary"(test.hex('aabbccdd'),2,256) = test.hex('bbccdd')) and (test."sub-binary"(test.hex('aabbccdd'),2,-1) = test.hex('')));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.3.query.sqlpp
new file mode 100644
index 0000000..d010324
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_01/and_01.3.query.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.
+ */
+
+use test;
+
+
+select element (x and y)
+from  ['true'] as x,
+      ['false'] as y
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.3.query.sqlpp
new file mode 100644
index 0000000..cc1c25c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null/and_null.3.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;
+
+
+(true and null);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.3.query.sqlpp
new file mode 100644
index 0000000..00a3681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/and_null_false/and_null_false.3.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;
+
+
+(false and null);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.3.query.sqlpp
new file mode 100644
index 0000000..c443f6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/boolean/not_01/not_01.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'not_x':test.not(true),'not_y':test.not(false),'not_z':test.not(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.3.query.sqlpp
new file mode 100644
index 0000000..bbbd5a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary/binary.3.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;
+
+
+[(test.hex('0A0A') > test.hex('0B')),(test.hex('0A0A') >= test.hex('0B')),(test.hex('0A0A') < test.hex('0B')),(test.hex('0A0A') <= test.hex('0B')),(test.hex('0A0A') = test.hex('0B')),(test.hex('0A0A') != test.hex('0B')),(test.base64('Cgo=') > test.base64('Cw==')),(test.base64('Cgo=') >= test.base64('Cw==')),(test.base64('Cgo=') < test.base64('Cw==')),(test.base64('Cgo=') <= test.base64('Cw==')),(test.base64('Cgo=') = test.base64('Cw==')),(test.base64('Cgo=') != test.base64('Cw==')),(test.hex('0A0A') = test.base64('Cgo=')),(test.hex('0B') = test.base64('Cw==')),(test.hex('0A0A') = test.base64('Cw==')),(test.hex('0B') = test.base64('Cgo='))];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.3.query.sqlpp
new file mode 100644
index 0000000..66ece7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/binary_null/binary_null.3.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;
+
+
+{'result1':(test.hex('AA') > [1][1]),'result2':([1][1] >= test.hex('AA')),'result3':(test.hex('AA') < [1][1]),'result4':([1][1] <= test.hex('AA')),'result5':(test.hex('AA') = [1][1]),'result6':([1][1] != test.hex('AA'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.3.query.sqlpp
new file mode 100644
index 0000000..95ffab2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/date_order/date_order.3.query.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.
+ */
+
+use test;
+
+
+with  d1 as test.date('2049-04-23'),
+      d2 as test.date('2012-02-29'),
+      d3 as test.date('2021-03-01'),
+      d4 as test.date('1362-02-28'),
+      d5 as test.date('1600-02-29'),
+      d6 as test.date('-0500-03-21')
+select element d
+from  [d1,d2,d3,d4,d5,d6] as d
+order by d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.3.query.sqlpp
new file mode 100644
index 0000000..5274e9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_order/datetime_order.3.query.sqlpp
@@ -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.
+ */
+
+use test;
+
+
+with  dt1 as test.datetime('2011-12-31T14:00:00-10:00'),
+      dt2 as test.datetime('2012-01-01T00:00:00Z'),
+      dt3 as test.datetime('2005-01-01T00:00:00+04:00'),
+      dt4 as test.datetime('2011-12-31T13:00:00-11:00'),
+      dt5 as test.datetime('2012-04-06T00:00:00Z'),
+      dt6 as test.datetime('-1937-07-07T23:00:00+08:00'),
+      dt7 as test.datetime('-1600-03-01T00:00:00.384+06:00'),
+      dt8 as test.datetime('-1600-02-29T23:59:59.999Z'),
+      dt9 as test.datetime('2000-02-29T23:59:59.999Z'),
+      dt10 as test.datetime('2000-03-01T01:59:59.999+07:00'),
+      dt11 as test.datetime('-1600-03-01T00:00:00.384-06:00')
+select element dt
+from  [dt1,dt2,dt3,dt4,dt5,dt6,dt7,dt8,dt9,dt10,dt11] as dt
+order by dt
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.1.ddl.sqlpp
new file mode 100644
index 0000000..2cab169
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Tweet as
+ closed {
+  id : int64,
+  tweetid : int64,
+  loc : point,
+  time : datetime,
+  text : string
+}
+
+create  table TwitterData(Tweet) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.2.update.sqlpp
new file mode 100644
index 0000000..b06a9d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.2.update.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;
+
+
+load  table TwitterData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/smalltweets.txt"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.3.query.sqlpp
new file mode 100644
index 0000000..1dcd5af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_range/datetime_range.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':t.id}
+from  TwitterData as t
+where ((t.time > test.datetime('2011-05-15T16:00:00Z')) and (t.time < test.datetime('2011-05-15T21:59:59Z')))
+order by t.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.3.query.sqlpp
new file mode 100644
index 0000000..0c756b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/datetime_tzeq/datetime_tzeq.3.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;
+
+
+{'result1':(test.datetime('2011-12-31T14:00:00-10:00') = test.datetime('2012-01-01T00:00:00Z')),'result2':(test.datetime('2000-03-01T02:00:00+04:00') = test.datetime('2000-02-29T22:00:00Z'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.1.ddl.sqlpp
new file mode 100644
index 0000000..ad56952
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check comparison and order-by for day-time-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.2.update.sqlpp
new file mode 100644
index 0000000..cc84682
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.2.update.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.
+ */
+/*
+ * Description      :   Check comparison and order-by for day-time-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.3.query.sqlpp
new file mode 100644
index 0000000..c391a03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/day_time_duration_order/day_time_duration_order.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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      :   Check comparison and order-by for day-time-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+
+use test;
+
+
+with  dr1 as test."day-time-duration"('P439D'),
+      dr2 as test."day-time-duration"('-PT328M'),
+      dr3 as test."day-time-duration"('-P48DT12M43.932S'),
+      dr4 as test."day-time-duration"('P12H')
+select element dr
+from  [dr1,dr2,dr3,dr4] as dr
+order by dr
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.3.query.sqlpp
new file mode 100644
index 0000000..1bedb4b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double/double.3.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;
+
+
+{'result1':(test.double('-6.5d') > test.int8('+1')),'result2':(test.double('-6.5d') >= test.int16('2')),'result3':(test.double('-6.5d') < test.int32('+3')),'result4':(test.double('-6.5d') <= test.int64('-4')),'result5':(test.double('-6.5d') = test.float('-5.5f')),'result6':(test.double('-6.5d') != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.3.query.sqlpp
new file mode 100644
index 0000000..ec3b27e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_gte_01/double_gte_01.3.query.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.
+ */
+
+use test;
+
+
+select element i
+from  [0.8,0.8999999761581421,0.9,0.901] as i
+where (i >= 0.9)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.3.query.sqlpp
new file mode 100644
index 0000000..dd07245
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/double_null/double_null.3.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;
+
+
+{'result1':(test.double('-6.5d') > [1][1]),'result2':([1][1] >= test.double('-6.5d')),'result3':(test.double('-6.5d') < [1][1]),'result4':([1][1] <= test.double('-6.5d')),'result5':(test.double('-6.5d') = [1][1]),'result6':([1][1] != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.3.query.sqlpp
new file mode 100644
index 0000000..b39e84e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/eq_01/eq_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [1,2,2] as x
+where (x = 2)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.3.query.sqlpp
new file mode 100644
index 0000000..fc32c8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float/float.3.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;
+
+
+{'result1':(test.float('-5.5f') > test.int8('+1')),'result2':(test.float('-5.5f') >= test.int16('2')),'result3':(test.float('-5.5f') < test.int32('+3')),'result4':(test.float('-5.5f') <= test.int64('-4')),'result5':(test.float('-5.5f') = test.float('-5.5f')),'result6':(test.float('-5.5f') != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.3.query.sqlpp
new file mode 100644
index 0000000..e17becc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/float_null/float_null.3.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;
+
+
+{'result1':(test.float('-6.5d') > [1][1]),'result2':([1][1] >= test.float('-6.5d')),'result3':(test.float('-6.5d') < [1][1]),'result4':([1][1] <= test.float('-6.5d')),'result5':(test.float('-6.5d') = [1][1]),'result6':([1][1] != test.float('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.3.query.sqlpp
new file mode 100644
index 0000000..cf44ba8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gt_01/gt_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [1,3,2] as x
+where (x > 1)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.3.query.sqlpp
new file mode 100644
index 0000000..a2d4a48
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/gte_01/gte_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [1,3,2] as x
+where (x >= 2)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.3.query.sqlpp
new file mode 100644
index 0000000..a2375e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16/int16.3.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;
+
+
+{'result1':(test.int16('2') > test.int8('+1')),'result2':(test.int16('2') >= test.int16('2')),'result3':(test.int16('2') < test.int32('+3')),'result4':(test.int16('2') <= test.int64('-4')),'result5':(test.int16('2') = test.float('-5.5f')),'result6':(test.int16('2') != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.3.query.sqlpp
new file mode 100644
index 0000000..eac566e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int16_null/int16_null.3.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;
+
+
+{'result1':(test.int16('3') > [1][1]),'result2':([1][1] >= test.int16('3')),'result3':(test.int16('3') < [1][1]),'result4':([1][1] <= test.int16('3')),'result5':(test.int16('3') = [1][1]),'result6':([1][1] != test.int16('3'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.3.query.sqlpp
new file mode 100644
index 0000000..4bc09d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32/int32.3.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;
+
+
+{'result1':(test.int32('+3') > test.int8('+1')),'result2':(test.int32('+3') >= test.int16('2')),'result3':(test.int32('+3') < test.int32('+3')),'result4':(test.int32('+3') <= test.int64('-4')),'result5':(test.int32('+3') = test.float('-5.5f')),'result6':(test.int32('+3') != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.3.query.sqlpp
new file mode 100644
index 0000000..a69d5e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int32_null/int32_null.3.query.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.
+ */
+
+{'result1':(int32('3') > [1][1]),'result2':([1][1] >= int32('3')),'result3':(int32('3') < [1][1]),'result4':([1][1] <= int32('3')),'result5':(int32('3') = [1][1]),'result6':([1][1] != int32('3'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.3.query.sqlpp
new file mode 100644
index 0000000..974406e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64/int64.3.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;
+
+
+{'result1':(test.int64('-4') > test.int8('+1')),'result2':(test.int64('-4') >= test.int16('2')),'result3':(test.int64('-4') <= test.int32('+3')),'result4':(test.int64('-4') < test.int64('-4')),'result5':(test.int64('-4') = test.float('-5.5f')),'result6':(test.int64('-4') != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.3.query.sqlpp
new file mode 100644
index 0000000..ae75b15
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int64_null/int64_null.3.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;
+
+
+{'result1':(test.int64('3') > [1][1]),'result2':([1][1] >= test.int64('3')),'result3':(test.int64('3') < [1][1]),'result4':([1][1] <= test.int64('3')),'result5':(test.int64('3') = [1][1]),'result6':([1][1] != test.int64('3'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.3.query.sqlpp
new file mode 100644
index 0000000..c69c506
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8/int8.3.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;
+
+
+{'result1':(test.int8('+1') > test.int8('+1')),'result2':(test.int8('+1') >= test.int16('2')),'result3':(test.int8('+1') < test.int32('+3')),'result4':(test.int8('+1') <= test.int64('-4')),'result5':(test.int8('+1') = test.float('-5.5f')),'result6':(test.int8('+1') != test.double('-6.5d'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.3.query.sqlpp
new file mode 100644
index 0000000..92a2164
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/int8_null/int8_null.3.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;
+
+
+{'result1':(test.int8('3') > [1][1]),'result2':([1][1] >= test.int8('3')),'result3':(test.int8('3') < [1][1]),'result4':([1][1] <= test.int8('3')),'result5':(test.int8('3') = [1][1]),'result6':([1][1] != test.int8('3'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.1.ddl.sqlpp
new file mode 100644
index 0000000..16922d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.1.ddl.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.
+ */
+/*
+ * Description  : a test case for equality comparisons for non-total-ordered types
+ * Expected Res : Success
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.2.update.sqlpp
new file mode 100644
index 0000000..16922d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.2.update.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.
+ */
+/*
+ * Description  : a test case for equality comparisons for non-total-ordered types
+ * Expected Res : Success
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.3.query.sqlpp
new file mode 100644
index 0000000..da2e983
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_equality/issue363_equality.3.query.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.
+ */
+/*
+ * Description  : a test case for equality comparisons for non-total-ordered types
+ * Expected Res : Success
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'duration':(duration('P3Y6M3DT9H5M2.348S') = duration('P3Y6M3DT9H5M2.348S')),'year-month-duration':("year-month-duration"('P3Y6M') = "year-month-duration"('P3Y6M')),'day-time-duration':("day-time-duration"('P3DT9H5M2.348S') = "day-time-duration"('P3DT9H5M2.348S')),'point':(point('47.44,80.65') = point('47.44,80.65')),'line':(line('10.1234,11.1e-1 +10.2E-2,-11.22') = line('10.1234,11.1e-1 +10.2E-2,-11.22')),'polygon':(polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75') = polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75')),'circle':(circle('0.1234,-1.00e-10 +10.5E-2') = circle('0.1234,-1.00e-10 +10.5E-2')),'rectangle':(rectangle('0.1234,-1.00e-10 5.5487,0.48765') = rectangle('0.1234,-1.00e-10 5.5487,0.48765')),'interval':("interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')) = "interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700'))),'duration2':(duration('P3Y6M3DT9H5M2.348S') != duration('P4Y6M3DT9H5M2.348S')),'year-month-duration2':("year-month-duration"('P3Y6M') != "year-month-duration"('P3Y7M')),'day-time-duration2':("day-time-duration"('P3DT9H5M2.348S') != "day-time-duration"('P3DT1H5M2.348S')),'point2':(point('47.44,80.65') != point('47.4444,80.65')),'line2':(line('10.1234,11.1e-1 +10.2E-2,-11.22') != line('10.5678,11.1e-1 +10.2E-2,-11.22')),'polygon2':(polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75') != polygon('-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75')),'circle2':(circle('0.1234,-1.00e-10 +10.5E-2') != circle('0.5678,-1.00e-10 +10.5E-2')),'rectangle2':(rectangle('0.1234,-1.00e-10 5.5487,0.48765') != rectangle('0.5678,-1.00e-10 5.5487,0.48765')),'interval2':("interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')) != "interval-from-datetime"(datetime('-1983-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ddl.sqlpp
new file mode 100644
index 0000000..eee8f10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of circle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.2.update.sqlpp
new file mode 100644
index 0000000..eee8f10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of circle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.3.query.sqlpp
new file mode 100644
index 0000000..28a7345
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of circle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'circle0':(circle('0.1234,-1.00e-10 +10.5E-2') > circle('0.5678,-1.00e-10 +10.5E-2')),'circle1':(circle('0.5678,-1.00e-10 +10.5E-2') < circle('0.1234,-1.00e-10 +10.5E-2')),'circle2':(circle('0.1234,-1.00e-10 +10.5E-2') >= circle('0.5678,-1.00e-10 +10.5E-2')),'circle3':(circle('0.5678,-1.00e-10 +10.5E-2') <= circle('0.1234,-1.00e-10 +10.5E-2'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ddl.sqlpp
new file mode 100644
index 0000000..05dcb09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of duration
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.2.update.sqlpp
new file mode 100644
index 0000000..05dcb09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of duration
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.3.query.sqlpp
new file mode 100644
index 0000000..de67fbf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of duration
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'duration0':(duration('P300Y6M3DT9H5M2.348S') > duration('P3Y6M3DT9H5M2.348S')),'duration1':(duration('P3Y6M3DT9H5M2.348S') < duration('P300Y6M3DT9H5M2.348S')),'duration2':(duration('P300Y6M3DT9H5M2.348S') >= duration('P3Y6M3DT9H5M2.348S')),'duration3':(duration('P3Y6M3DT9H5M2.348S') <= duration('P300Y6M3DT9H5M2.348S'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ddl.sqlpp
new file mode 100644
index 0000000..7f75e0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of interval
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.2.update.sqlpp
new file mode 100644
index 0000000..7f75e0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of interval
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.3.query.sqlpp
new file mode 100644
index 0000000..c72d273
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of interval
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'interval0':("interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')) > "interval-from-datetime"(datetime('-1983-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700'))),'interval1':("interval-from-datetime"(datetime('-1983-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')) < "interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700'))),'interval2':("interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')) >= "interval-from-datetime"(datetime('-1983-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700'))),'interval3':("interval-from-datetime"(datetime('-1983-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')) <= "interval-from-datetime"(datetime('-1987-11-19T02:43:57.938+08:00'),datetime('19991112T124935948-0700')))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.1.ddl.sqlpp
new file mode 100644
index 0000000..d6a23e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of line
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.2.update.sqlpp
new file mode 100644
index 0000000..d6a23e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of line
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.3.query.sqlpp
new file mode 100644
index 0000000..893bda4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of line
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'line0':(line('10.1234,11.1e-1 +10.2E-2,-11.22') > line('10.1234,11.1e-1 +10.2E-2,-11.22')),'line1':(line('10.1234,11.1e-1 +10.2E-2,-11.22') < line('10.1234,11.1e-1 +10.2E-2,-11.22')),'line2':(line('10.1234,11.1e-1 +10.2E-2,-11.22') >= line('10.1234,11.1e-1 +10.2E-2,-11.22')),'line3':(line('10.1234,11.1e-1 +10.2E-2,-11.22') <= line('10.1234,11.1e-1 +10.2E-2,-11.22'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.1.ddl.sqlpp
new file mode 100644
index 0000000..3fd57ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of point
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.2.update.sqlpp
new file mode 100644
index 0000000..3fd57ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of point
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.3.query.sqlpp
new file mode 100644
index 0000000..789fbae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of point
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'point0':(point('47.44,80.65') > point('47.4444,80.65')),'point1':(point('47.4444,80.65') < point('47.44,80.65')),'point2':(point('47.44,80.65') >= point('47.4444,80.65')),'point3':(point('47.4444,80.65') <= point('47.44,80.65'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ddl.sqlpp
new file mode 100644
index 0000000..8a88042
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of polygon
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.update.sqlpp
new file mode 100644
index 0000000..8a88042
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of polygon
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.query.sqlpp
new file mode 100644
index 0000000..0bb4118
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of polygon
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'polygon0':(polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75') > polygon('-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75')),'polygon1':(polygon('-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75') < polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75')),'polygon2':(polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75') >= polygon('-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75')),'polygon3':(polygon('-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75') <= polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ddl.sqlpp
new file mode 100644
index 0000000..ad49cad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ddl.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of rectangle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.update.sqlpp
new file mode 100644
index 0000000..ad49cad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.update.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of rectangle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.query.sqlpp
new file mode 100644
index 0000000..6db0ae6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.query.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.
+ */
+/*
+ * Description  : a test case for inequality comparisons of rectangle
+ * Expected Res : Failure
+ * Date         : 9 May 2013
+ * Issue        : 363
+ */
+
+{'rectangle0':(rectangle('0.1234,-1.00e-10 5.5487,0.48765') > rectangle('0.5678,-1.00e-10 5.5487,0.48765')),'rectangle1':(rectangle('0.5678,-1.00e-10 5.5487,0.48765') < rectangle('0.1234,-1.00e-10 5.5487,0.48765')),'rectangle2':(rectangle('0.1234,-1.00e-10 5.5487,0.48765') >= rectangle('0.5678,-1.00e-10 5.5487,0.48765')),'rectangle3':(rectangle('0.5678,-1.00e-10 5.5487,0.48765') <= rectangle('0.1234,-1.00e-10 5.5487,0.48765'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.3.query.sqlpp
new file mode 100644
index 0000000..654a1e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lt_01/lt_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [1,3,2] as x
+where (x < 3)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.3.query.sqlpp
new file mode 100644
index 0000000..db96736
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/lte_01/lte_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [1,3,2] as x
+where (x <= 2)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.3.query.sqlpp
new file mode 100644
index 0000000..3a6a7f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/neq_01/neq_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [1,2,2] as x
+where (x != 2)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.3.query.sqlpp
new file mode 100644
index 0000000..6c95365
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/numeric-comparison_01/numeric-comparison_01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+with  l as [1.100000f,1.000000f,1.200000f,0.9,1.3,1,2]
+select element [i,j,'=',(i = j),'<',(i < j),'<=',(i <= j),'>',(i > j),'>=',(i >= j)]
+from  l as i,
+      l as j
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.3.query.sqlpp
new file mode 100644
index 0000000..b67afce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string/string.3.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;
+
+
+{'result1':('AA' > 'B'),'result2':('AA' >= 'B'),'result3':('AA' < 'B'),'result4':('AA' <= 'B'),'result5':('AA' = 'B'),'result6':('AA' != 'B')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.3.query.sqlpp
new file mode 100644
index 0000000..7127ed3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/string_null/string_null.3.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;
+
+
+{'result1':('AA' > [1][1]),'result2':([1][1] >= 'AA'),'result3':('AA' < [1][1]),'result4':([1][1] <= 'AA'),'result5':('AA' = [1][1]),'result6':([1][1] != 'AA')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.3.query.sqlpp
new file mode 100644
index 0000000..5f377b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/time_order/time_order.3.query.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.
+ */
+
+use test;
+
+
+with  t1 as test.time('13:00:00.382-10:00'),
+      t2 as test.time('23:59:59.999Z'),
+      t3 as test.time('22:00:00+03:00'),
+      t4 as test.time('00:00:00.00Z'),
+      t5 as test.time('00:00:00.00-02:00'),
+      t6 as test.time('00:00:00.47+04:00')
+select element t
+from  [t1,t2,t3,t4,t5,t6] as t
+order by t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.1.ddl.sqlpp
new file mode 100644
index 0000000..eb49ec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check comparison and order-by for year-month-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.2.update.sqlpp
new file mode 100644
index 0000000..2c9a982
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.2.update.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.
+ */
+/*
+ * Description      :   Check comparison and order-by for year-month-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.3.query.sqlpp
new file mode 100644
index 0000000..19fc713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/year_month_duration_order/year_month_duration_order.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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      :   Check comparison and order-by for year-month-duration
+ * Expected Result  :   Success
+ * Date             :   May 18, 2013
+ */
+
+use test;
+
+
+with  dr1 as test."year-month-duration"('P439Y'),
+      dr2 as test."year-month-duration"('-P328M'),
+      dr3 as test."year-month-duration"('-P48Y12M'),
+      dr4 as test."year-month-duration"('P12M')
+select element dr
+from  [dr1,dr2,dr3,dr4] as dr
+order by dr
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.3.query.sqlpp
new file mode 100644
index 0000000..bbbbefc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/add-null/add-null.3.query.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.
+ */
+/*
+ * Description      :   Add anything plus null, the result should be null.
+ * Expected Result  :   Success
+ * Date             :   19th July 2012
+ */
+
+(1 + 10 + 20 + null);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.3.query.sqlpp
new file mode 100644
index 0000000..efbaaa6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/binary_01/binary_01.3.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;
+
+
+[test.hex('ABCDEF0123456789'),test.hex('abcdef0123456789'),test.hex('0A0B0C0D0E0F'),test.hex('01020304050607080900'),test.hex(''),test.base64('0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM+/'),test.base64(''),test.base64('QXN0ZXJpeA=='),test.base64('QXN0ZXJpeAE='),test.base64('QXN0ZXJpeAE8')];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.3.query.sqlpp
new file mode 100644
index 0000000..0261222
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/boolean_01/boolean_01.3.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;
+
+
+{'boolean1':test.boolean('true'),'boolean2':test.boolean('false')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.3.query.sqlpp
new file mode 100644
index 0000000..9125879
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/circle_01/circle_01.3.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;
+
+
+{'circle1':test.circle('10.1234,11.1e-1 +10.2E-2'),'circle2':test.circle('0.1234,-1.00e-10 +10.5E-2')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.3.query.sqlpp
new file mode 100644
index 0000000..7b5394a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/date_01/date_01.3.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;
+
+
+{'date1':test.date('2010-10-30'),'date2':test.date('1987-11-19'),'date3':test.date('-1987-11-19'),'date4':test.date('0001-12-27'),'date5':test.date('-1951-12-27'),'date6':test.date('-2043-11-19'),'date7':test.date('-19280329'),'date8':test.date('19280329'),'date9':test.date('19000228'),'date10':test.date('20000229')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.query.sqlpp
new file mode 100644
index 0000000..07ed68a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.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;
+
+
+{'datetime1':test.datetime('2010-10-30T10:50:56.999+05:45'),'datetime2':test.datetime('2010-10-30T10:30:56.250-10:00'),'datetime3':test.datetime('1987-11-19T09:20:00.200Z'),'datetime4':test.datetime('1987-11-19T10:50:56Z'),'datetime5':test.datetime('-1987-11-19T10:50:56.099-05:30'),'datetime6':test.datetime('-0001-11-19T10:50:56.719Z'),'datetime7':test.datetime('1951-12-27T12:20:15Z'),'datetime8':test.datetime('2043-11-19T10:50:56.719Z'),'datetime9':test.datetime('-19280329T174937374-0630'),'datetime10':test.datetime('-19280329T174937374+0630'),'datetime11':test.datetime('-19280329T174937374'),'datetime12':test.datetime('-19280329T174937374+0630'),'datetime13':test.datetime('-19280329T17493737+0630'),'datetime14':test.datetime('-19280301T05493737+0630')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.3.query.sqlpp
new file mode 100644
index 0000000..c320657
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/double_01/double_01.3.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;
+
+
+{'double1':test.double('NaN'),'double2':test.double('INF'),'double3':test.double('-INF'),'double4':test.double('-80.20d'),'double5':test.double('-20.56e-30'),'double6':test.double('-20.56e-300')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.1.ddl.sqlpp
new file mode 100644
index 0000000..ef8506f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : test duration constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.2.update.sqlpp
new file mode 100644
index 0000000..0ce54d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.2.update.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.
+ */
+/*
+ * Description  : test duration constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.3.query.sqlpp
new file mode 100644
index 0000000..689fae16
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_01/duration_01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : test duration constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ */
+
+use test;
+
+
+{'duration1':test.duration('P30Y10M25DT13H12M50S'),'duration2':test.duration('P25DT13H12M50S'),'duration3':test.duration('PT13H12M50S'),'duration4':test.duration('P30YT12MS'),'duration5':test.duration('PT13H'),'duration6':test.duration('-P30Y10M25DT13H12M50S'),'duration7':test.duration('-P25DT13H12M50S'),'duration8':test.duration('-PT13H50S'),'duration9':test.duration('P120D'),'duration10':test.duration('-P28M'),'duration11':test.duration('PT29M90.937S'),'duration12':test.duration('P300Y15M60DT300H98M482.435S')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.1.ddl.sqlpp
new file mode 100644
index 0000000..a06e1d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.1.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.
+ */
+/*
+ * Description  : test sub type duration (year-month-duration and day-time-duration) constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * issue        : 363
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.2.update.sqlpp
new file mode 100644
index 0000000..7806d1f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.2.update.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.
+ */
+/*
+ * Description  : test sub type duration (year-month-duration and day-time-duration) constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * issue        : 363
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.3.query.sqlpp
new file mode 100644
index 0000000..8eae7c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/duration_02/duration_02.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : test sub type duration (year-month-duration and day-time-duration) constructors 
+ * Expected Res : Success
+ * Date         : 7 May 2013
+ * issue        : 363
+ */
+
+use test;
+
+
+{'duration1':test."year-month-duration"('P30Y10M'),'duration2':test."day-time-duration"('P25DT13H12M50S'),'duration3':test."day-time-duration"('PT13H12M50S'),'duration4':test."year-month-duration"('P30Y'),'duration5':test."day-time-duration"('PT13H'),'duration6':test."year-month-duration"('-P30Y10M'),'duration7':test."day-time-duration"('-P25DT13H12M50S'),'duration8':test."day-time-duration"('-PT13H50S'),'duration9':test."day-time-duration"('P120D'),'duration10':test."year-month-duration"('-P28M'),'duration11':test."day-time-duration"('PT29M90.937S'),'duration12':test."year-month-duration"('P300Y15M')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.3.query.sqlpp
new file mode 100644
index 0000000..759e5b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/float_01/float_01.3.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;
+
+
+{'float1':test.float('NaN'),'float2':test.float('INF'),'float3':test.float('-INF'),'float4':test.float('-80.20'),'float5':test.float('-20.56e-30')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.3.query.sqlpp
new file mode 100644
index 0000000..7fbc6e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/int_01/int_01.3.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;
+
+
+{'int8':test.int8('+80i8'),'int16':test.int16('160'),'int32':test.int32('+320i32'),'int64':test.int64('640'),'int8_2':test.int8('-80'),'int16_2':test.int16('-160i16'),'int32_2':test.int32('-320'),'int64_2':test.int64('-640i64'),'int64_min':test.int64('-9223372036854775808')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.3.query.sqlpp
new file mode 100644
index 0000000..83ffa9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/interval/interval.3.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;
+
+
+{'interval11':test."interval-from-date"(test.date('2010-10-30'),test.date('2012-10-21')),'interval12':test."interval-from-date"('2010-10-30',test.date('2012-10-21')),'interval13':test."interval-from-date"(test.date('2010-10-30'),'2012-10-21'),'interval14':test."interval-from-date"('2010-10-30','2012-10-21'),'interval15':test."interval-from-date"(null,'2012-10-21'),'interval16':test."interval-from-date"('2010-10-30',null),'interval21':test."interval-from-time"(test.time('03:04:05.678-11:00'),test.time('232425267+0200')),'interval22':test."interval-from-time"('03:04:05.678-11:00',test.time('232425267+0200')),'interval23':test."interval-from-time"(test.time('03:04:05.678-11:00'),'232425267+0200'),'interval24':test."interval-from-time"('03:04:05.678-11:00','232425267+0200'),'interval25':test."interval-from-time"(null,test.time('232425267+0200')),'interval26':test."interval-from-time"(test.time('03:04:05.678-11:00'),null),'interval31':test."interval-from-datetime"(test.datetime('-1987-11-19T02:43:57.938+08:00'),test.datetime('19991112T124935948-0700')),'interval32':test."interval-from-datetime"('-1987-11-19T02:43:57.938+08:00',test.datetime('19991112T124935948-0700')),'interval33':test."interval-from-datetime"(test.datetime('-1987-11-19T02:43:57.938+08:00'),'19991112T124935948-0700'),'interval34':test."interval-from-datetime"('-1987-11-19T02:43:57.938+08:00','19991112T124935948-0700'),'interval35':test."interval-from-datetime"(null,test.datetime('19991112T124935948-0700')),'interval36':test."interval-from-datetime"(test.datetime('-1987-11-19T02:43:57.938+08:00'),null),'interval41':test."interval-start-from-date"(test.date('0001-12-27'),test.duration('P3Y394DT48H398.483S')),'interval42':test."interval-start-from-date"('0001-12-27',test.duration('P3Y394DT48H398.483S')),'interval43':test."interval-start-from-date"(test.date('0001-12-27'),'P3Y394DT48H398.483S'),'interval44':test."interval-start-from-date"('0001-12-27','P3Y394DT48H398.483S'),'interval45':test."interval-start-from-date"(null,test.duration('P3Y394DT48H398.483S')),'interval46':test."interval-start-from-date"(test.date('0001-12-27'),null),'interval51':test."interval-start-from-time"(test.time('20:03:20.948'),test.duration('P60DT48M389.938S')),'interval52':test."interval-start-from-time"('20:03:20.948',test.duration('P60DT48M389.938S')),'interval53':test."interval-start-from-time"(test.time('20:03:20.948'),'P60DT48M389.938S'),'interval54':test."interval-start-from-time"('20:03:20.948','P60DT48M389.938S'),'interval55':test."interval-start-from-time"(null,test.duration('P60DT48M389.938S')),'interval56':test."interval-start-from-time"(test.time('20:03:20.948'),null),'interval61':test."interval-start-from-datetime"(test.datetime('-2043-11-19T15:32:39.293'),test.duration('P439Y3M20DT20H39M58.949S')),'interval62':test."interval-start-from-datetime"('-2043-11-19T15:32:39.293',test.duration('P439Y3M20DT20H39M58.949S')),'interval63':test."interval-start-from-datetime"(test.datetime('-2043-11-19T15:32:39.293'),'P439Y3M20DT20H39M58.949S'),'interval64':test."interval-start-from-datetime"('-2043-11-19T15:32:39.293','P439Y3M20DT20H39M58.949S'),'interval65':test."interval-start-from-datetime"(null,test.duration('P439Y3M20DT20H39M58.949S')),'interval66':test."interval-start-from-datetime"(test.datetime('-2043-11-19T15:32:39.293'),null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.3.query.sqlpp
new file mode 100644
index 0000000..94f0c7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/line_01/line_01.3.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;
+
+
+{'line1':test.line('10.1234,11.1e-1 +10.2E-2,-11.22'),'line2':test.line('0.1234,-1.00e-10 +10.5E-2,-01.02')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.3.query.sqlpp
new file mode 100644
index 0000000..242d6c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/point_01/point_01.3.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;
+
+
+{'point1':test.point('80.10d, -10E5'),'point3d1':test.point3d('5e2, -10E+5, +10.5e-10d'),'point2':test.point('5.10E-10d, -10E5'),'point3d2':test.point3d('0.5e+2d, -10.0E+5d, +10.05e-10')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.3.query.sqlpp
new file mode 100644
index 0000000..c87e983
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/polygon_01/polygon_01.3.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;
+
+
+{'polygon1':test.polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'),'polygon2':test.polygon('-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.3.query.sqlpp
new file mode 100644
index 0000000..99a1c04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-01/primitive-01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name : primitive-01.aql
+ * Description    : Test primitive integer type int8 constructor function with boundary values
+ * Success        : Yes
+ * Date           : May 7th 2012
+ *
+ */
+
+{'$a':int8('-127'),'$b':int8('127'),'$c':int8('0'),'$d':int8('1'),'$e':int8('-1')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.3.query.sqlpp
new file mode 100644
index 0000000..ad82347
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-02/primitive-02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name : primitive-02.aql
+ * Description    : Test primitive integer type int16 constructor function with boundary values
+ * Success        : Yes
+ * Date           : May 7th 2012
+ *
+ */
+
+{'$a':int16('-32767'),'$b':int16('32767'),'$c':int16('0'),'$d':int16('1'),'$e':int16('-1'),'$f':int16('16383'),'$g':int16('-16383')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.3.query.sqlpp
new file mode 100644
index 0000000..3297c9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-03/primitive-03.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name : primitive-03.aql
+ * Description    : Test primitive integer type int32 constructor function with boundary values
+ * Success        : Yes
+ * Date           : May 7th 2012
+ *
+ */
+
+{'$a':int32('-2147483647'),'$b':int32('2147483647'),'$c':int32('0'),'$d':int32('1'),'$e':int32('-1'),'$f':int32('1073741828'),'$g':int32('-1073741828')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.3.query.sqlpp
new file mode 100644
index 0000000..8103517
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/primitive-04/primitive-04.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name : primitive-04.aql
+ * Description    : Test primitive integer type int64 constructor functions with boundary values
+ * Success        : Yes
+ * Date           : May 7th 2012
+ *
+ */
+
+{'$a':int64('9222872036854775809'),'$b':int64('-9222872036854775809'),'$c':int64('0'),'$d':int64('1'),'$e':int64('-1'),'$f':int64('4611436018427387904'),'$g':int64('-4611436018427387904')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.1.ddl.sqlpp
new file mode 100644
index 0000000..e81b2f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.1.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.
+ */
+/*
+ * Description  : create a rectangle constructor
+ * Expected Res : Success
+ * Date         : 18 April 2013
+ * Issue        : 272
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.2.update.sqlpp
new file mode 100644
index 0000000..ffe5e49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.2.update.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.
+ */
+/*
+ * Description  : create a rectangle constructor
+ * Expected Res : Success
+ * Date         : 18 April 2013
+ * Issue        : 272
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.3.query.sqlpp
new file mode 100644
index 0000000..e27ce38
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/rectangle_01/rectangle_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : create a rectangle constructor
+ * Expected Res : Success
+ * Date         : 18 April 2013
+ * Issue        : 272
+ */
+
+use test;
+
+
+{'rectangle1':test.rectangle('5.1,11.8 87.6,15.6548'),'rectangle2':test.rectangle('0.1234,-1.00e-10 5.5487,0.48765')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.3.query.sqlpp
new file mode 100644
index 0000000..ef0ff22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/string_01/string_01.3.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;
+
+
+{'string1':test.string('true'),'string2':test.string('false"')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.3.query.sqlpp
new file mode 100644
index 0000000..d807ee3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/time_01/time_01.3.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;
+
+
+{'time1':test.time('10:50:56.200+05:00'),'time2':test.time('10:50:56.200-10:15'),'time3':test.time('10:50:56'),'time4':test.time('10:50:56.200Z'),'time5':test.time('23:59:59.999-13:30'),'time6':test.time('00:00:00.000+14:45'),'time7':test.time('12:59:00.019-01:00'),'time8':test.time('12:59:00.01-01:00'),'time9':test.time('12:59:00.019-01:00'),'time10':test.time('12590001-0100'),'time11':test.time('125900019+0100')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.3.query.sqlpp
new file mode 100644
index 0000000..b58cdb3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/uuid_01/uuid_01.3.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;
+
+
+{'uuid1':test.uuid('02a199ca-bf58-412e-bd9f-60a0c975a8ac'),'uuid2':test.uuid('8cea25ab-55f8-467e-929d-94888f754832')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.1.ddl.sqlpp
new file mode 100644
index 0000000..9a3f59a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.1.ddl.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to access datasets.
+ * Expected Res : Success
+ * Date         : 29th Aug 2012
+ */
+
+drop  database student if exists;
+drop  database teacher if exists;
+create  database student;
+
+create  database teacher;
+
+use student;
+
+
+use teacher;
+
+
+create type student.stdType as
+{
+  id : int64,
+  name : string,
+  age : int64,
+  sex : string,
+  dept : string
+}
+
+create type teacher.tchrType as
+{
+  id : int64,
+  name : string,
+  age : int64,
+  sex : string,
+  dept : string
+}
+
+create  table student.ugdstd(stdType) primary key id;
+
+create  table student.gdstd(stdType) primary key id;
+
+create  table teacher.prof(tchrType) primary key id;
+
+create  table teacher.pstdoc(tchrType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.2.update.sqlpp
new file mode 100644
index 0000000..b2bb45e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to access datasets.
+ * Expected Res : Success
+ * Date         : 29th Aug 2012
+ */
+
+use student;
+
+
+use teacher;
+
+
+insert into student.ugdstd
+select element {'id':457,'name':'John Doe','age':22,'sex':'M','dept':'Dance'};
+insert into student.gdstd
+select element {'id':418,'name':'John Smith','age':26,'sex':'M','dept':'Economics'};
+insert into teacher.prof
+select element {'id':152,'name':'John Meyer','age':42,'sex':'M','dept':'History'};
+insert into teacher.pstdoc
+select element {'id':259,'name':'Sophia Reece','age':36,'sex':'F','dept':'Anthropology'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.3.query.sqlpp
new file mode 100644
index 0000000..97fd4bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv01/cross-dv01.3.query.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.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to access datasets.
+ * Expected Res : Success
+ * Date         : 29th Aug 2012
+ */
+
+select element {'ug-student':s,'prof':p,'grd-student':a,'postdoc':b}
+from  "student.ugdstd" as s,
+      "teacher.prof" as p,
+      "student.gdstd" as a,
+      "teacher.pstdoc" as b
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.1.ddl.sqlpp
new file mode 100644
index 0000000..cbee950
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types and query Metadata to verify.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+drop  database student if exists;
+drop  database teacher if exists;
+create  database student;
+
+create  database teacher;
+
+create type student.stdType as
+{
+  id : int32,
+  name : string,
+  age : int32,
+  sex : string,
+  dept : string
+}
+
+create type teacher.tchrType as
+{
+  id : int32,
+  name : string,
+  age : int32,
+  sex : string,
+  dept : string
+}
+
+create  table student.ugdstd(stdType) primary key id;
+
+create  table student.gdstd(stdType) primary key id;
+
+create  table teacher.prof(tchrType) primary key id;
+
+create  table teacher.pstdoc(tchrType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.2.update.sqlpp
new file mode 100644
index 0000000..3a92d61
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.2.update.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.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types and query Metadata to verify.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+insert into student.ugdstd
+select element {'id':457,'name':'John Doe','age':22,'sex':'M','dept':'Dance'};
+insert into student.gdstd
+select element {'id':418,'name':'John Smith','age':26,'sex':'M','dept':'Economics'};
+insert into teacher.prof
+select element {'id':152,'name':'John Meyer','age':42,'sex':'M','dept':'History'};
+insert into teacher.pstdoc
+select element {'id':259,'name':'Sophia Reece','age':36,'sex':'F','dept':'Anthropology'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.3.query.sqlpp
new file mode 100644
index 0000000..757d591
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv02/cross-dv02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types and query Metadata to verify.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+select element l
+from  "Metadata.Dataset" as l
+where ((l.DataverseName = 'student') or (l.DataverseName = 'teacher'))
+order by l.DatasetName
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.1.ddl.sqlpp
new file mode 100644
index 0000000..8b2244e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : Query metadata to verify datasets are dropped.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+drop  database student if exists;
+drop  database teacher if exists;
+create  database student;
+
+create  database teacher;
+
+use student;
+
+
+use teacher;
+
+
+create type student.stdType as
+{
+  id : int64,
+  name : string,
+  age : int64,
+  sex : string,
+  dept : string
+}
+
+create type teacher.tchrType as
+{
+  id : int64,
+  name : string,
+  age : int64,
+  sex : string,
+  dept : string
+}
+
+create  table student.ugdstd(stdType) primary key id;
+
+create  table student.gdstd(stdType) primary key id;
+
+create  table teacher.prof(tchrType) primary key id;
+
+create  table teacher.pstdoc(tchrType) primary key id;
+
+drop  table student.ugdstd;
+drop  table student.gdstd;
+drop  table teacher.prof;
+drop  table teacher.pstdoc;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.2.update.sqlpp
new file mode 100644
index 0000000..508296a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.2.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : Query metadata to verify datasets are dropped.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.3.query.sqlpp
new file mode 100644
index 0000000..c43f41fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv03/cross-dv03.3.query.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.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : Query metadata to verify datasets are dropped.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+select element count((
+    select element l
+    from  "Metadata.Dataset" as l
+    where ((l.DataverseName = 'student') or (l.DataverseName = 'teacher'))
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.1.ddl.sqlpp
new file mode 100644
index 0000000..83038c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.1.ddl.sqlpp
@@ -0,0 +1,79 @@
+/*
+ * 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  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : re create the datasets 
+ *              : Query metadata to verify datasets are created.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+drop  database student if exists;
+drop  database teacher if exists;
+create  database student;
+
+create  database teacher;
+
+use student;
+
+
+use teacher;
+
+
+create type student.stdType as
+{
+  id : int32,
+  name : string,
+  age : int32,
+  sex : string,
+  dept : string
+}
+
+create type teacher.tchrType as
+{
+  id : int32,
+  name : string,
+  age : int32,
+  sex : string,
+  dept : string
+}
+
+create  table student.ugdstd(stdType) primary key id;
+
+create  table student.gdstd(stdType) primary key id;
+
+create  table teacher.prof(tchrType) primary key id;
+
+create  table teacher.pstdoc(tchrType) primary key id;
+
+drop  table student.ugdstd;
+drop  table student.gdstd;
+drop  table teacher.prof;
+drop  table teacher.pstdoc;
+create  table student.ugdstd(stdType) primary key id;
+
+create  table student.gdstd(stdType) primary key id;
+
+create  table teacher.prof(tchrType) primary key id;
+
+create  table teacher.pstdoc(tchrType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.2.update.sqlpp
new file mode 100644
index 0000000..25fcdd8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : re create the datasets 
+ *              : Query metadata to verify datasets are created.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.3.query.sqlpp
new file mode 100644
index 0000000..7c229bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv04/cross-dv04.3.query.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.
+ */
+/*
+ * Description  : Test cross dataverse functionality
+ *              : use dataverse statement is now optional.
+ *              : Use fully qualified names to create datasets, types.
+ *              : drop datasets using fully qualified names
+ *              : re create the datasets 
+ *              : Query metadata to verify datasets are created.
+ * Expected Res : Success
+ * Date         : 28th Aug 2012
+ */
+
+select element l
+from  "Metadata.Dataset" as l
+where ((l.DataverseName = 'student') or (l.DataverseName = 'teacher'))
+order by l.DatasetName
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.1.ddl.sqlpp
new file mode 100644
index 0000000..97d37b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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     : Use fully qualified name to create dataset, type and index
+ *                 : and to access dataset
+ * Expected Result : Success
+ * Date            : 29th August 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create  table test.employee(Emp) primary key id;
+
+create  index idx_employee_f_l_name  on test.employee (fname,lname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.2.update.sqlpp
new file mode 100644
index 0000000..8927466
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Use fully qualified name to create dataset, type and index
+ *                 : and to access dataset
+ * Expected Result : Success
+ * Date            : 29th August 2012
+ */
+
+use test;
+
+
+load  table test.employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.3.query.sqlpp
new file mode 100644
index 0000000..e25dc80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv07/cross-dv07.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Use fully qualified name to create dataset, type and index
+ *                 : and to access dataset
+ * Expected Result : Success
+ * Date            : 29th August 2012
+ */
+
+select element l
+from  "test.employee" as l
+where ((l.fname = 'Julio') and (l.lname = 'Isa'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.1.ddl.sqlpp
new file mode 100644
index 0000000..27b71fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.1.ddl.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.
+ */
+/*
+ * Description  : Create two UDFs in two different dataverses and create datasets in tose dvs
+ *              : access the datasets from the UDF defined in the other dataverse and invoke one of the UDF
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.2.update.sqlpp
new file mode 100644
index 0000000..f211ce6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.2.update.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : Create two UDFs in two different dataverses and create datasets in tose dvs
+ *              : access the datasets from the UDF defined in the other dataverse and invoke one of the UDF
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ */
+
+insert into test.t1
+select element {'id':24};
+insert into test.t1
+select element {'id':23};
+insert into test.t1
+select element {'id':21};
+insert into test.t1
+select element {'id':44};
+insert into test.t1
+select element {'id':64};
+insert into fest.t1
+select element {'id':24};
+insert into fest.t1
+select element {'id':23};
+insert into fest.t1
+select element {'id':21};
+insert into fest.t1
+select element {'id':44};
+insert into fest.t1
+select element {'id':64};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.3.query.sqlpp
new file mode 100644
index 0000000..49cd80b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv08/cross-dv08.3.query.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.
+ */
+/*
+ * Description  : Create two UDFs in two different dataverses and create datasets in tose dvs
+ *              : access the datasets from the UDF defined in the other dataverse and invoke one of the UDF
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ */
+
+{'a':test.f1(),'b':fest.f1()};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.1.ddl.sqlpp
new file mode 100644
index 0000000..59958b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.1.ddl.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.
+ */
+/*
+ * Description  : Create user defined funs. in two different dataverses
+ *              : and invoke one of them.
+ *              : In this test we use fully qualified names to access and create the UDFs.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.2.update.sqlpp
new file mode 100644
index 0000000..59958b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.2.update.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.
+ */
+/*
+ * Description  : Create user defined funs. in two different dataverses
+ *              : and invoke one of them.
+ *              : In this test we use fully qualified names to access and create the UDFs.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.3.query.sqlpp
new file mode 100644
index 0000000..d0f3cd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv09/cross-dv09.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create user defined funs. in two different dataverses
+ *              : and invoke one of them.
+ *              : In this test we use fully qualified names to access and create the UDFs.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+use testdv1;
+
+
+select element testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.1.ddl.sqlpp
new file mode 100644
index 0000000..89a6884
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.1.ddl.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.
+ */
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Invoke one UDF from the body of the other UDF.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.2.update.sqlpp
new file mode 100644
index 0000000..89a6884
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.2.update.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.
+ */
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Invoke one UDF from the body of the other UDF.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.3.query.sqlpp
new file mode 100644
index 0000000..e1dad33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv11/cross-dv11.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Invoke one UDF from the body of the other UDF.
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+use testdv1;
+
+
+select element testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.1.ddl.sqlpp
new file mode 100644
index 0000000..9862c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.1.ddl.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.
+ */
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Bind the results returned by each UDF to a variable and return those variables
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.2.update.sqlpp
new file mode 100644
index 0000000..9862c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.2.update.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.
+ */
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Bind the results returned by each UDF to a variable and return those variables
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.3.query.sqlpp
new file mode 100644
index 0000000..1d10e49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv12/cross-dv12.3.query.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.
+ */
+/* 
+ * Description  : Create two UDFs in two different dataverses
+ *              : Bind the results returned by each UDF to a variable and return those variables
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+use testdv1;
+
+
+use testdv2;
+
+
+{'fun-01':testdv1.fun01(),'fun-02':testdv2.fun02()};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.1.ddl.sqlpp
new file mode 100644
index 0000000..6f99df6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.1.ddl.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.
+ */
+/* 
+ * Description  : Create UDFs in different dataverses
+ *              : Test for recursion in those UDFs
+ * Expected Res : Failure - Recursion is not allowed!
+ * Date         : 31st Aug 2012
+ * Ignored      : This test is currently not part of the test build, because it being a negative test case expectedly throws an exception. 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.2.update.sqlpp
new file mode 100644
index 0000000..6f99df6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.2.update.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.
+ */
+/* 
+ * Description  : Create UDFs in different dataverses
+ *              : Test for recursion in those UDFs
+ * Expected Res : Failure - Recursion is not allowed!
+ * Date         : 31st Aug 2012
+ * Ignored      : This test is currently not part of the test build, because it being a negative test case expectedly throws an exception. 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.3.query.sqlpp
new file mode 100644
index 0000000..60ee553
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv13/cross-dv13.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Description  : Create UDFs in different dataverses
+ *              : Test for recursion in those UDFs
+ * Expected Res : Failure - Recursion is not allowed!
+ * Date         : 31st Aug 2012
+ * Ignored      : This test is currently not part of the test build, because it being a negative test case expectedly throws an exception. 
+ */
+
+use testdv1;
+
+
+select element testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.1.ddl.sqlpp
new file mode 100644
index 0000000..4891f12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke UDF in return clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.2.update.sqlpp
new file mode 100644
index 0000000..4891f12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke UDF in return clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.3.query.sqlpp
new file mode 100644
index 0000000..4448d8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv14/cross-dv14.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke UDF in return clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : 31st Aug 2012
+ */
+
+use testdv1;
+
+
+testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.1.ddl.sqlpp
new file mode 100644
index 0000000..8e48045
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.1.ddl.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.
+ */
+/*
+ * Description  : Create user defined functions using fully qualified names
+ *              : verify their details in Function dataset in Metadata dataverse.
+ * Expected Res :
+ * Date         : 30th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.2.update.sqlpp
new file mode 100644
index 0000000..8e48045
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.2.update.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.
+ */
+/*
+ * Description  : Create user defined functions using fully qualified names
+ *              : verify their details in Function dataset in Metadata dataverse.
+ * Expected Res :
+ * Date         : 30th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.3.query.sqlpp
new file mode 100644
index 0000000..d08dece
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv15/cross-dv15.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create user defined functions using fully qualified names
+ *              : verify their details in Function dataset in Metadata dataverse.
+ * Expected Res :
+ * Date         : 30th Aug 2012
+ */
+
+select element l
+from  "Metadata.Function" as l
+where (l.DataverseName = 'testdv1')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.1.ddl.sqlpp
new file mode 100644
index 0000000..c70f3db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.1.ddl.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.
+ */
+/*
+ * Description  : Detect Recursion in UDFs
+ * Expected Res : Failure
+ * Date         : 30 Aug 2012
+ * Ignored      : Not part of test build, as its a negative test case that thrwos an exception
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.2.update.sqlpp
new file mode 100644
index 0000000..c70f3db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.2.update.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.
+ */
+/*
+ * Description  : Detect Recursion in UDFs
+ * Expected Res : Failure
+ * Date         : 30 Aug 2012
+ * Ignored      : Not part of test build, as its a negative test case that thrwos an exception
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.3.query.sqlpp
new file mode 100644
index 0000000..1668b59
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv16/cross-dv16.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Detect Recursion in UDFs
+ * Expected Res : Failure
+ * Date         : 30 Aug 2012
+ * Ignored      : Not part of test build, as its a negative test case that thrwos an exception
+ */
+
+use testdv1;
+
+
+select element testdv1.fun01();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.1.ddl.sqlpp
new file mode 100644
index 0000000..8ae2238
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.1.ddl.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.
+ */
+/*
+ * Decription   : Create UDF to query two different datasets that are in tow different dataverses.
+ * Expected Res : Success
+ * Date         : Sep 7 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.2.update.sqlpp
new file mode 100644
index 0000000..e6955f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.2.update.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Decription   : Create UDF to query two different datasets that are in tow different dataverses.
+ * Expected Res : Success
+ * Date         : Sep 7 2012
+ */
+
+insert into test.t1
+select element {'id':24};
+insert into test.t1
+select element {'id':23};
+insert into test.t1
+select element {'id':21};
+insert into test.t1
+select element {'id':44};
+insert into test.t1
+select element {'id':64};
+insert into fest.t1
+select element {'id':24};
+insert into fest.t1
+select element {'id':23};
+insert into fest.t1
+select element {'id':21};
+insert into fest.t1
+select element {'id':44};
+insert into fest.t1
+select element {'id':64};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.3.query.sqlpp
new file mode 100644
index 0000000..2460cb6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv17/cross-dv17.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Decription   : Create UDF to query two different datasets that are in tow different dataverses.
+ * Expected Res : Success
+ * Date         : Sep 7 2012
+ */
+
+use fest;
+
+
+select element fest.f1();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.1.ddl.sqlpp
new file mode 100644
index 0000000..546d1d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.1.ddl.sqlpp
@@ -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  : Create two dataverses and one dataset in each of the dataverse
+ *              : insert data and query using the datasets using fully qualified names and return results.
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ * Ignored      : Not part of the current test build because of Issue 199
+ */
+
+drop  database test if exists;
+drop  database fest if exists;
+create  database test;
+
+create  database fest;
+
+create type test.testtype as
+{
+  id : int32
+}
+
+create type fest.testtype as
+{
+  id : int32
+}
+
+create  table test.t1(testtype) primary key id;
+
+create  table fest.t1(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.2.update.sqlpp
new file mode 100644
index 0000000..7f0165a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.2.update.sqlpp
@@ -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  : Create two dataverses and one dataset in each of the dataverse
+ *              : insert data and query using the datasets using fully qualified names and return results.
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ * Ignored      : Not part of the current test build because of Issue 199
+ */
+
+insert into test.t1
+select element {'id':24};
+insert into test.t1
+select element {'id':23};
+insert into test.t1
+select element {'id':21};
+insert into test.t1
+select element {'id':44};
+insert into test.t1
+select element {'id':64};
+insert into fest.t1
+select element {'id':24};
+insert into fest.t1
+select element {'id':23};
+insert into fest.t1
+select element {'id':21};
+insert into fest.t1
+select element {'id':44};
+insert into fest.t1
+select element {'id':64};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.3.query.sqlpp
new file mode 100644
index 0000000..1168648
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv18/cross-dv18.3.query.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.
+ */
+/*
+ * Description  : Create two dataverses and one dataset in each of the dataverse
+ *              : insert data and query using the datasets using fully qualified names and return results.
+ * Expected Res : Success
+ * Date         : Sep 7th 2012
+ * Ignored      : Not part of the current test build because of Issue 199
+ */
+
+{'a':(
+    select element l
+    from  "fest.t1" as l
+),'b':(
+    select element m
+    from  "test.t1" as m
+)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.1.ddl.sqlpp
new file mode 100644
index 0000000..8f41665
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.1.ddl.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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  : Create internal and external datasets in more than one dataverse and query metadata to verify entries in Metadata.
+ * Expected Res : Success
+ * Date         : Sep 20 2012
+ */
+
+drop  database test1 if exists;
+drop  database test2 if exists;
+create  database test1;
+
+create  database test2;
+
+create type test1.testtype as
+{
+  id : int32,
+  name : string,
+  loc : point,
+  time : datetime
+}
+
+create type test2.testtype as
+{
+  id : int32,
+  name : string?,
+  loc : point,
+  time : datetime
+}
+
+create type test1.Tweet as
+{
+  id : int32,
+  tweetid : int64,
+  loc : point,
+  time : datetime,
+  text : string
+}
+
+create  table test1.t1(testtype) primary key id;
+
+create  table test2.t2(testtype) primary key id;
+
+create  table test2.t3(testtype) primary key id;
+
+create  table test1.t2(testtype) primary key id;
+
+create  table test1.t3(testtype) primary key id;
+
+create  table test2.t4(testtype) primary key id;
+
+create external  table test1.TwitterData(Tweet) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.2.update.sqlpp
new file mode 100644
index 0000000..0f84ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.2.update.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.
+ */
+/*
+ * Description  : Create internal and external datasets in more than one dataverse and query metadata to verify entries in Metadata.
+ * Expected Res : Success
+ * Date         : Sep 20 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.3.query.sqlpp
new file mode 100644
index 0000000..a6dd771
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv19/cross-dv19.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create internal and external datasets in more than one dataverse and query metadata to verify entries in Metadata.
+ * Expected Res : Success
+ * Date         : Sep 20 2012
+ */
+
+select element l
+from  "Metadata.Dataset" as l
+where ((l.DataverseName = 'test1') or (l.DataverseName = 'test2') or (l.DataverseName = 'TwitterData'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.1.ddl.sqlpp
new file mode 100644
index 0000000..74dc32f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test various syntax for dataset access
+ *              : Using parentheses for dataset access is now optional
+ *              : New syntax can use fully qualified names to access datasets.
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database student if exists;
+drop  database teacher if exists;
+create  database student;
+
+create  database teacher;
+
+create type student.stdType as
+{
+  id : int64,
+  name : string,
+  age : int64,
+  sex : string,
+  dept : string
+}
+
+create type teacher.tchrType as
+{
+  id : int64,
+  name : string,
+  age : int64,
+  sex : string,
+  dept : string
+}
+
+create  table student.ugdstd(stdType) primary key id;
+
+create  table student.gdstd(stdType) primary key id;
+
+create  table teacher.prof(tchrType) primary key id;
+
+create  table teacher.pstdoc(tchrType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.2.update.sqlpp
new file mode 100644
index 0000000..c2af92f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+insert into student.ugdstd
+select element {'id':457,'name':'John Doe','age':22,'sex':'M','dept':'Dance'};
+insert into student.gdstd
+select element {'id':418,'name':'John Smith','age':26,'sex':'M','dept':'Economics'};
+insert into teacher.prof
+select element {'id':152,'name':'John Meyer','age':42,'sex':'M','dept':'History'};
+insert into teacher.pstdoc
+select element {'id':259,'name':'Sophia Reece','age':36,'sex':'F','dept':'Anthropology'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.3.query.sqlpp
new file mode 100644
index 0000000..c820707
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/cross-dv20/cross-dv20.3.query.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 {'ug-student':s,'prof':p,'grd-student':a,'postdoc':b}
+from  "student.ugdstd" as s,
+      "teacher.prof" as p,
+      "student.gdstd" as a,
+      "teacher.pstdoc" as b
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..47cf7e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  cashBack : int32,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create  table test.Customers(CustomerType) primary key cid;
+
+drop  table test.Customers;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.3.query.sqlpp
new file mode 100644
index 0000000..d768aef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/drop_dataset/drop_dataset.3.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.
+ */
+
+select element x
+from  "Metadata.Dataset" as x
+where ((x.DataverseName = 'test') and (x.DatasetName = 'Customers'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.1.ddl.sqlpp
new file mode 100644
index 0000000..8f74bc9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.1.ddl.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 test1 if exists;
+drop  database test2 if exists;
+create  database test1;
+
+create  database test2;
+
+create type test1.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test1.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test2.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test2.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create  table test1.Customers(CustomerType) primary key cid;
+
+create  table test2.Customers(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.2.update.sqlpp
new file mode 100644
index 0000000..edcde6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.2.update.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.
+ */
+
+load  table test1.Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+insert into test2.Customers
+select element x
+from  "test1.Customers" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.3.query.sqlpp
new file mode 100644
index 0000000..90dcca2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.3.query.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.
+ */
+
+use test2;
+
+
+select element c
+from  "test2.Customers" as c
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..3a5cc50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Use fully qualified dataset names to insert into target dataset by doing a select on source dataset.
+ * Expected Res : Success
+ * Date         : Sep 19 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testtype as
+{
+  id : int32,
+  name : string
+}
+
+create  table test.t1(testtype) primary key id;
+
+create  table test.t2(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.2.update.sqlpp
new file mode 100644
index 0000000..690142a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.2.update.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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  : Use fully qualified dataset names to insert into target dataset by doing a select on source dataset.
+ * Expected Res : Success
+ * Date         : Sep 19 2012
+ */
+
+insert into test.t1
+select element {'id':456,'name':'Roger'};
+insert into test.t1
+select element {'id':351,'name':'Bob'};
+insert into test.t1
+select element {'id':257,'name':'Sammy'};
+insert into test.t1
+select element {'id':926,'name':'Richard'};
+insert into test.t1
+select element {'id':482,'name':'Kevin'};
+insert into test.t2
+select element {'id':438,'name':'Ravi'};
+insert into test.t2
+select element {'id':321,'name':'Bobby'};
+insert into test.t2
+select element {'id':219,'name':'Sam'};
+insert into test.t2
+select element {'id':851,'name':'Ricardo'};
+insert into test.t2
+select element {'id':201,'name':'Kelvin'};
+insert into test.t1
+select element l
+from  "test.t2" as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.3.query.sqlpp
new file mode 100644
index 0000000..bda0242
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/insert_from_source_dataset/insert_from_source_dataset.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Use fully qualified dataset names to insert into target dataset by doing a select on source dataset.
+ * Expected Res : Success
+ * Date         : Sep 19 2012
+ */
+
+use test;
+
+
+select element l
+from  "test.t1" as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.1.ddl.sqlpp
new file mode 100644
index 0000000..30aa0ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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 test1 if exists;
+drop  database test2 if exists;
+create  database test1;
+
+create  database test2;
+
+create type test1.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test1.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create  table test1.Customers(CustomerType) primary key cid;
+
+create type test2.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create  table test2.Orders(OrderType) primary key oid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.2.update.sqlpp
new file mode 100644
index 0000000..8621d40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.2.update.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.
+ */
+
+use test1;
+
+
+use test2;
+
+
+load  table test1.Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+load  table test2.Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.3.query.sqlpp
new file mode 100644
index 0000000..45451cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test1;
+
+
+use test2;
+
+
+select element {'cust_name':c.name,'cust_age':c.age,'order_total':o.total,'orderList':[o.oid,o.cid]}
+from  "test1.Customers" as c,
+      "test2.Orders" as o
+where (c.cid = o.cid)
+order by c.name,o.total
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.3.query.sqlpp
new file mode 100644
index 0000000..632281f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/cross-dataverse/metadata_dataset/metadata_dataset.3.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.
+ */
+
+select element c
+from  "Metadata.Dataset" as c
+where (c.DataverseName = 'Metadata')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/csv/basic-types/basic-types.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/csv/basic-types/basic-types.1.ddl.sqlpp
new file mode 100644
index 0000000..ad9feb0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/csv/basic-types/basic-types.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AllType as
+{
+  id : int64,
+  string : string,
+  float : float,
+  double : double,
+  boolean : boolean,
+  int8 : int8,
+  int16 : int16,
+  int32 : int32,
+  int64 : int64,
+  date : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  point : point,
+  point3d : point3d,
+  line : line,
+  rectangle : rectangle,
+  polygon : polygon,
+  circle : circle,
+  binary : binary,
+  uuid : uuid
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/csv/basic-types/basic-types.2.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/csv/basic-types/basic-types.2.query.sqlpp
new file mode 100644
index 0000000..e06f0bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/csv/basic-types/basic-types.2.query.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;
+
+
+set "output-record-type" "AllType";
+
+select element {'id':10,'string':test.string('Nancy'),'float':32.500000f,'double':test.double('-2013.5938237483274'),'boolean':true,'int8':test.int8('125'),'int16':test.int16('32765'),'int32':test.int32('294967295'),'int64':test.int64('1700000000000000000'),'date':test.date('-2011-01-27'),'time':test.time('12:20:30Z'),'datetime':test.datetime('-1951-12-27T12:20:30'),'duration':test.duration('P10Y11M12DT10H50M30S'),'point':test.point('41.00,44.00'),'point3d':test.point3d('44.00,13.00,41.00'),'line':test.line('10.1,11.1 10.2,11.2'),'rectangle':test.rectangle('5.1,11.8 87.6,15.6548'),'polygon':test.polygon('1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8'),'circle':test.circle('10.1,11.1 10.2'),'binary':test.hex('ABCDEF0123456789'),'uuid':test.uuid('5c848e5c-6b6a-498f-8452-8847a2957421')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.1.ddl.sqlpp
new file mode 100644
index 0000000..5b3545f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use custord;
+
+
+create type custord.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type custord.CustomerType as
+{
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type custord.OrderType as
+{
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type custord.CustomerOrdersType as
+{
+  cid : int32,
+  cust : CustomerType,
+  orders : [OrderType]
+}
+
+create  table Customers3(CustomerType) primary key cid;
+
+create  table Orders3(OrderType) primary key oid;
+
+create  table CustomerOrders3(CustomerOrdersType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.3.query.sqlpp
new file mode 100644
index 0000000..f294b75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/co/co.3.query.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.
+ */
+
+use custord;
+
+
+select element co1
+from  CustomerOrders3 as co1
+where some o1 in co1.orders satisfies (o1.oid = 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.1.ddl.sqlpp
new file mode 100644
index 0000000..adf9d0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.3.query.sqlpp
new file mode 100644
index 0000000..c774fd8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_01/customer_q_01.3.query.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 element c
+from  Customers as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.1.ddl.sqlpp
new file mode 100644
index 0000000..b2dbf37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.3.query.sqlpp
new file mode 100644
index 0000000..86b03cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_02/customer_q_02.3.query.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.
+ */
+
+use test;
+
+
+select element {'id':c.cid,'nestedRecord':nestedRec,'order_id':nestedRec.oid}
+from  Customers as c
+with  nestedRec as c.lastorder
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.1.ddl.sqlpp
new file mode 100644
index 0000000..b2dbf37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.3.query.sqlpp
new file mode 100644
index 0000000..6baabd6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_03/customer_q_03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'id':c.cid,'list1':c1,'list2':c2,'list3':c3,'list4':c4}
+from  Customers as c
+with  nestedRec as c.lastorder,
+      c1 as [c.cid,nestedRec.oid],
+      c2 as {{c.cid,nestedRec.oid}},
+      c3 as [c.lastorder,nestedRec],
+      c4 as {{c.lastorder,nestedRec}}
+where (c.cid >= test.int32('3'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.1.ddl.sqlpp
new file mode 100644
index 0000000..b2dbf37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.3.query.sqlpp
new file mode 100644
index 0000000..a725391
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_04/customer_q_04.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':c.cid,'custname':c.name,'age':c.age,'MathcashBack':rec}
+from  Customers as c
+with  rec as {'cashBack':c.cashBack,'cashBack+5':(c.cashBack + 5),'cashBack-5':(c.cashBack - 5),'cashBack*5':(c.cashBack * 5),'cashBack/5':(c.cashBack / 5),'-cashBack':-c.cashBack}
+where (c.cid >= test.int32('3'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.1.ddl.sqlpp
new file mode 100644
index 0000000..b2dbf37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.3.query.sqlpp
new file mode 100644
index 0000000..5b33254
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_05/customer_q_05.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'custname':c.name,'age':c.age,'MathAge':rec}
+from  Customers as c
+with  rec as {'age':c.age,'age+5':(c.age + 5),'age-5':(c.age - 5),'age*5':(c.age * 5),'age/5':(c.age / 5),'-age':-c.age}
+where (c.cid >= test.int32('3'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.1.ddl.sqlpp
new file mode 100644
index 0000000..adf9d0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.3.query.sqlpp
new file mode 100644
index 0000000..d5afe16
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_06/customer_q_06.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'customerid':c.name,'orderedlist':n}
+from  Customers as c
+with  rec as c.lastorder,
+      m as [c.cid,rec.oid],
+      n as [m[?],m[1],m[4]]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.1.ddl.sqlpp
new file mode 100644
index 0000000..adf9d0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.3.query.sqlpp
new file mode 100644
index 0000000..3344c77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_07/customer_q_07.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'customerid':c.name,'unorderedlist':n}
+from  Customers as c
+with  rec as c.lastorder,
+      m as [c.cid,rec.oid],
+      n as {{m[?],m[1],m[4]}}
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.1.ddl.sqlpp
new file mode 100644
index 0000000..adf9d0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.3.query.sqlpp
new file mode 100644
index 0000000..4c04280
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/customer_q_08/customer_q_08.3.query.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.
+ */
+
+use test;
+
+
+select element {'custname':c.name,'custage':c.age}
+from  Customers as c
+where (c.age < 15)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.1.ddl.sqlpp
new file mode 100644
index 0000000..c665354
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type test.CustomerOrdersType as
+{
+  cid : int64,
+  cust : CustomerType,
+  orders : [OrderType]
+}
+
+create  table Customers1(CustomerType) primary key cid;
+
+create  table Orders1(OrderType) primary key oid;
+
+create  table CustomerOrders1(CustomerOrdersType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.2.update.sqlpp
new file mode 100644
index 0000000..cc8a73b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.2.update.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.
+ */
+
+use test;
+
+
+load  table Customers1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm")) pre-sorted;
+
+load  table Orders1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.sqlpp
new file mode 100644
index 0000000..960cfe5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_01/denorm-cust-order_01.3.update.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.
+ */
+
+use test;
+
+
+insert into CustomerOrders1
+select element {'cid':cid,'cust':cust,'orders':o}
+from  Customers1 as c,
+      Orders1 as o
+where ((c.cid = o.cid) and (c.age < 21) and (c.total > 50.0))
+group by c.cid as cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.1.ddl.sqlpp
new file mode 100644
index 0000000..c5706d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type test.CustomerOrdersType as
+{
+  cid : int64,
+  cust : CustomerType,
+  orders : [OrderType]
+}
+
+create  table Customers2(CustomerType) primary key cid;
+
+create  table Orders2(OrderType) primary key oid;
+
+create  table CustomerOrders2(CustomerOrdersType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.sqlpp
new file mode 100644
index 0000000..a94bccf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm"));
+
+load  table Orders2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm"));
+
+insert into CustomerOrders2
+select element {'cid':c.cid,'cust':c,'orders':orders}
+from  Customers2 as c
+with  orders as (
+      select element o
+      from  Orders2 as o
+      where (o.cid = c.cid)
+      order by o.oid
+  )
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.3.query.sqlpp
new file mode 100644
index 0000000..2db331b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.3.query.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.
+ */
+
+use test;
+
+
+select element co
+from  CustomerOrders2 as co
+order by co.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.1.ddl.sqlpp
new file mode 100644
index 0000000..13e7eda
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create type test.CustomerOrdersType as
+{
+  cid : int64,
+  cust : CustomerType,
+  orders : [OrderType]
+}
+
+create  table Customers3(CustomerType) primary key cid;
+
+create  table Orders3(OrderType) primary key oid;
+
+create  table CustomerOrders3(CustomerOrdersType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.2.update.sqlpp
new file mode 100644
index 0000000..83013db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.2.update.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.
+ */
+
+use test;
+
+
+load  table Customers3 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm")) pre-sorted;
+
+load  table Orders3 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.sqlpp
new file mode 100644
index 0000000..b8c3cb9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.3.update.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.
+ */
+
+use test;
+
+
+insert into CustomerOrders3
+select element {'cid':c.cid,'cust':c,'orders':orders}
+from  Customers3 as c
+with  orders as (
+      select element o
+      from  Orders3 as o
+      where (o.cid = c.cid)
+      order by o.orderpriority desc
+  )
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.4.query.sqlpp
new file mode 100644
index 0000000..082c1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/denorm-cust-order_03/denorm-cust-order_03.4.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'order':o1,'ordcust':(
+        select element co2.cust
+        from  CustomerOrders3 as co2
+        where some o2 in co2.orders satisfies (o2.oid = o1.oid)
+    )}
+from  CustomerOrders3 as co1,
+      co1.orders as o1
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.1.ddl.sqlpp
new file mode 100644
index 0000000..da8e957
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.1.ddl.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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerOrderType as
+{
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  orders : [OrderType]
+}
+
+create type test.OrderType as
+{
+  oid : int32,
+  cid : int32,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  table CustomerOrders(CustomerOrderType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.2.update.sqlpp
new file mode 100644
index 0000000..3584c6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.2.update.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;
+
+
+load  table CustomerOrders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/custorder-tiny.adm"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.3.query.sqlpp
new file mode 100644
index 0000000..157efa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/freq-clerk/freq-clerk.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'clerk':clerk,'ordercount':count}
+from  CustomerOrders as c,
+      c.orders as o
+group by o.clerk as clerk
+with  count as test.count(o)
+order by count,clerk desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.1.ddl.sqlpp
new file mode 100644
index 0000000..0ecc663
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.3.query.sqlpp
new file mode 100644
index 0000000..ffa8148
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_01/join_q_01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'cust_name':c.name,'cust_age':c.age,'order_total':o.total,'orderList':[o.oid,o.cid]}
+from  Customers as c,
+      Orders as o
+where (c.cid = o.cid)
+order by c.name,o.total
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.1.ddl.sqlpp
new file mode 100644
index 0000000..0ecc663
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.3.query.sqlpp
new file mode 100644
index 0000000..643f37e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_02/join_q_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'cust_name':c.name,'order_total':o.total,'orderedlist':ol,'unorderedlist':ul}
+from  Customers as c,
+      Orders as o
+with  rec as c.lastorder,
+      ol as [o.oid,rec.oid,o.cid],
+      ul as {{o.oid,rec.oid,o.cid}}
+where (c.cid = o.cid)
+order by c.name,o.total
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.1.ddl.sqlpp
new file mode 100644
index 0000000..0ecc663
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.3.query.sqlpp
new file mode 100644
index 0000000..7b34440
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_03/join_q_03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'cust_name':c.name,'order_total':o.total,'orderedlist':ol,'unorderedlist':ul,'ol_item1':ol[0],'ol_item2':ol[1],'ol_item5':ol[4],'ul_item1':ul[?]}
+from  Customers as c,
+      Orders as o
+with  rec as c.lastorder,
+      ol as [o.oid,rec.oid,o.cid],
+      ul as {{o.oid,rec.oid,o.cid}}
+where (c.cid = o.cid)
+order by c.name,o.total
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.1.ddl.sqlpp
new file mode 100644
index 0000000..0e10306
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : This test case is to verify the fix for issue51
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.2.update.sqlpp
new file mode 100644
index 0000000..456375c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue51
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.3.query.sqlpp
new file mode 100644
index 0000000..f090a40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/join_q_04/join_q_04.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue51
+
+use test;
+
+
+select element {'cust_name':c.name,'order_ids':(
+        select element o.oid
+        from  Orders as o
+        where (c.cid = o.cid)
+        order by o.oid
+    )}
+from  Customers as c
+order by c.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.1.ddl.sqlpp
new file mode 100644
index 0000000..e2f6e71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create  table c1(CustomerType) primary key cid;
+
+create  table c2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.2.update.sqlpp
new file mode 100644
index 0000000..207c3be
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.2.update.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;
+
+
+load  table c1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.3.update.sqlpp
new file mode 100644
index 0000000..ea87ac9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.3.update.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.
+ */
+
+use test;
+
+
+insert into c2
+select element c
+from  c1 as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.4.query.sqlpp
new file mode 100644
index 0000000..8f87674
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/load-test/load-test.4.query.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.
+ */
+
+use test;
+
+
+select element c
+from  c2 as c
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.1.ddl.sqlpp
new file mode 100644
index 0000000..8f46bf4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.3.query.sqlpp
new file mode 100644
index 0000000..15152e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_01/order_q_01.3.query.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 element c
+from  Orders as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.1.ddl.sqlpp
new file mode 100644
index 0000000..8f46bf4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.3.query.sqlpp
new file mode 100644
index 0000000..e84ab27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_02/order_q_02.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'id':o.cid,'list1':c1,'list2':c2,'list3':c3,'list4':c4}
+from  Orders as o
+with  c1 as [o.orderstatus,o.clerk],
+      c2 as {{o.orderstatus,o.clerk}},
+      c3 as [o.heList,o.openlist,o.loc,o.line,o.poly,o.lastorder],
+      c4 as [o.heList,o.openlist,o.loc,o.line,o.poly,o.lastorder]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.1.ddl.sqlpp
new file mode 100644
index 0000000..8f46bf4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.3.query.sqlpp
new file mode 100644
index 0000000..b7ccf4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_03/order_q_03.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'orderid':o.oid,'ordertot':o.total,'list':c1,'item1':c1[0],'item2':c1[1],'item3':c1[2]}
+from  Orders as o
+with  c1 as [o.orderstatus,o.clerk],
+      c2 as {{o.orderstatus,o.clerk}},
+      c3 as [o.heList,o.openlist,o.loc,o.line,o.poly,o.lastorder],
+      c4 as [o.heList,o.openlist,o.loc,o.line,o.poly,o.lastorder]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.1.ddl.sqlpp
new file mode 100644
index 0000000..8f46bf4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.3.query.sqlpp
new file mode 100644
index 0000000..4a3c923
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_04/order_q_04.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'orderid':o.oid,'ordertot':o.total,'list':c3,'item1':c3[0],'item2':c3[1],'item5':c3[5],'item10':c3[10]}
+from  Orders as o
+with  c1 as [o.orderstatus,o.clerk],
+      c2 as {{o.orderstatus,o.clerk}},
+      c3 as [o.heList,o.openlist,o.loc,o.line,o.poly,o.lastorder],
+      c4 as [o.heList,o.openlist,o.loc,o.line,o.poly,o.lastorder]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.1.ddl.sqlpp
new file mode 100644
index 0000000..8f46bf4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.3.query.sqlpp
new file mode 100644
index 0000000..7271316
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_05/order_q_05.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'orderid':o.oid,'ordertot':o.total,'emptyorderedlist':c1,'emptyunorderedlist':c2,'olist_item1':c1[0],'olist_item5':c1[4],'ulist_item1':c2[?]}
+from  Orders as o
+with  c1 as [],
+      c2 as {{}}
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.1.ddl.sqlpp
new file mode 100644
index 0000000..8f46bf4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.3.query.sqlpp
new file mode 100644
index 0000000..a8859c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/custord/order_q_06/order_q_06.3.query.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.
+ */
+
+use test;
+
+
+select element {'item1':c3[?]}
+from  Orders as o
+with  c3 as {{o.heList,o.openlist}}
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.1.ddl.sqlpp
new file mode 100644
index 0000000..363d8e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  street : string,
+  city : string,
+  zip : string,
+  latlong : point
+}
+
+create type test.UserType as
+{
+  name : string,
+  email : string,
+  interests : {{string}},
+  address : AddressType,
+  member_of : {{{
+          sig_id : int64,
+          chapter_name : string,
+          member_since : date
+      }
+}}
+}
+
+create external  table User(UserType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/events/tiny/user.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.3.query.sqlpp
new file mode 100644
index 0000000..7d79c93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q1/q1.3.query.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.
+ */
+
+use test;
+
+
+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/runtimets/queries_sqlpp/dapd/q2/q2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.1.ddl.sqlpp
new file mode 100644
index 0000000..e23b2e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  street : string,
+  city : string,
+  zip : string,
+  latlong : point
+}
+
+create type test.EventType as
+ closed {
+  event_id : int64,
+  name : string,
+  location : AddressType?,
+  organizers : {{{
+          name : string
+      }
+}},
+  sponsoring_sigs : [{
+          sig_id : int64,
+          chapter_name : string
+      }
+],
+  interest_keywords : {{string}},
+  price : double?,
+  start_time : datetime,
+  end_time : datetime
+}
+
+create external  table Event(EventType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/events/tiny/event.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.3.query.sqlpp
new file mode 100644
index 0000000..3b64539
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q2/q2.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 element {'sig_id':sig_id,'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_id as sig_id
+with  sig_sponsorship_count as test.count(es),
+      by_chapter as (
+      select element {'chapter_name':chapter_name,'escount':test.count(e)}
+      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/runtimets/queries_sqlpp/dapd/q3/q3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.1.ddl.sqlpp
new file mode 100644
index 0000000..770526e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  street : string,
+  city : string,
+  zip : string,
+  latlong : point2d
+}
+
+create type test.UserType as
+{
+  name : string,
+  interests : {{string}},
+  address : AddressType,
+  member_of : {{{
+          sig_id : int64,
+          chapter_name : string,
+          member_since : date
+      }
+}}
+}
+
+create  table User(UserType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.2.update.sqlpp
new file mode 100644
index 0000000..d312e33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.2.update.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;
+
+
+load  table User using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/events/tiny/user.adm"),("format"="json")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.3.query.sqlpp
new file mode 100644
index 0000000..875397a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dapd/q3/q3.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+
+set "simthreshold" ".5f";
+
+select element {'user_name':user.name,'similar_users':similar_users}
+from  User as user
+with  similar_users as (
+      select element {'user_name':similar_user.name}
+      from  User as similar_user
+      with  sim as test."similarity-jaccard"(user.interests,similar_user.interests)
+      where ((user.name != similar_user.name) and (user.interests ~= similar_user.interests))
+      order by sim desc
+      limit 10
+  )
+order by user.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/distinct/query-issue443-2/query-issue443-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/distinct/query-issue443-2/query-issue443-2.3.query.sqlpp
new file mode 100644
index 0000000..f2b9a49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/distinct/query-issue443-2/query-issue443-2.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue443
+ * https://code.google.com/p/asterixdb/issues/detail?id=443
+ * Expected Res : Success
+ * Date         : 22th May 2013
+ */
+
+select element a
+from  [{'f':19,'g':1},{'f':12,'g':2},{'f':10,'g':1},{'f':17,'g':1},{'f':12,'g':4}] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/distinct/query-issue443/query-issue443.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/distinct/query-issue443/query-issue443.3.query.sqlpp
new file mode 100644
index 0000000..fd430f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/distinct/query-issue443/query-issue443.3.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue443
+
+select element a
+from  [{'f':19},{'f':12},{'f':10},{'f':17},{'f':12}] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ddl.sqlpp
new file mode 100644
index 0000000..a24401f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : compact-dataset-and-its-indexes.aql
+ * Description     : This test is intended to test the compact statement which merge the disk components of a dataset and
+ * all of its indexes.
+ * Expected Result : Success
+ * Date            : Sep 19 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ddl.sqlpp
new file mode 100644
index 0000000..873c727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.update.sqlpp
new file mode 100644
index 0000000..3e22ee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.update.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;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.query.sqlpp
new file mode 100644
index 0000000..5295e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.1.ddl.sqlpp
new file mode 100644
index 0000000..d773f9a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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  : Create and drop and recreate the same closed type, here type has optional fields.
+ *              : verify correctness by querying metadata.
+ * Date         : 11th Feb 2013
+ * Expected Res : Success
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  salary : double?,
+  name : string,
+  durtn : duration?,
+  inter : interval,
+  dt : date?,
+  tm : time,
+  pt : point?
+}
+
+drop type test.TestType;
+create type test.TestType as
+ closed {
+  id : int32,
+  salary : double?,
+  name : string,
+  durtn : duration?,
+  inter : interval,
+  dt : date?,
+  tm : time,
+  pt : point?
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.3.query.sqlpp
new file mode 100644
index 0000000..9dc1b48
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-cltype/create-drop-cltype.3.query.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.
+ */
+/*
+ * Description  : Create and drop and recreate the same closed type, here type has optional fields.
+ *              : verify correctness by querying metadata.
+ * Date         : 11th Feb 2013
+ * Expected Res : Success
+ */
+
+use test;
+
+
+select element l
+from  "Metadata.Datatype" as l
+where (l.DatatypeName = 'TestType')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.1.ddl.sqlpp
new file mode 100644
index 0000000..871b4fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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  : Create and drop and recreate the same open type, here type has optional fields.
+ *              : verify correctness by querying metadata.
+ * Date         : 11th Feb 2013
+ * Expected Res : Success
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  salary : double?,
+  name : string,
+  durtn : duration?,
+  inter : interval,
+  dt : date?,
+  tm : time,
+  pt : point?
+}
+
+drop type test.TestType;
+create type test.TestType as
+{
+  id : int32,
+  salary : double?,
+  name : string,
+  durtn : duration?,
+  inter : interval,
+  dt : date?,
+  tm : time,
+  pt : point?
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.3.query.sqlpp
new file mode 100644
index 0000000..44d6903
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/create-drop-opntype/create-drop-opntype.3.query.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.
+ */
+/*
+ * Description  : Create and drop and recreate the same open type, here type has optional fields.
+ *              : verify correctness by querying metadata.
+ * Date         : 11th Feb 2013
+ * Expected Res : Success
+ */
+
+use test;
+
+
+select element l
+from  "Metadata.Datatype" as l
+where (l.DatatypeName = 'TestType')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..e8ceb6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.sqlpp
new file mode 100644
index 0000000..873c727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp
new file mode 100644
index 0000000..3e22ee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.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;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp
new file mode 100644
index 0000000..5295e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..e8ceb6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.2.update.sqlpp
new file mode 100644
index 0000000..4e28a49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+delete l from LineItem
+ where (l.l_orderkey >= 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.3.query.sqlpp
new file mode 100644
index 0000000..5016728
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.3.query.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.
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.2.update.sqlpp
new file mode 100644
index 0000000..19ddd63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.2.update.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.
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+delete l from LineItem
+;
+delete o from Orders
+;
+delete s from Supplier
+;
+delete s from Region
+;
+delete s from Nation
+;
+delete s from Part
+;
+delete s from Partsupp
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.3.query.sqlpp
new file mode 100644
index 0000000..695ad6e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-multi-statement/delete-multi-statement.3.query.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 tpch;
+
+
+select element c
+from  Customer as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change.sqlpp
new file mode 100644
index 0000000..576e434
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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  : Test variant syntax for delete
+ *              : Ending semi-colon is optional for delete
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+delete l from LineItem
+ where (l.l_orderkey >= 10);
+write output to nc1:"rttest/dml_delete-syntax-change.adm"
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.1.ddl.sqlpp
new file mode 100644
index 0000000..87876f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.1.ddl.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.
+ */
+/*
+ * Description  : Test variant syntax for delete
+ *              : Ending semi-colon is optional for delete
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.2.update.sqlpp
new file mode 100644
index 0000000..4e28a49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+delete l from LineItem
+ where (l.l_orderkey >= 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.3.query.sqlpp
new file mode 100644
index 0000000..5016728
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/delete-syntax-change/delete-syntax-change.3.query.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.
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ddl.sqlpp
new file mode 100644
index 0000000..ddf6cb9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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     : Drop empty secondary index.
+ * Expected Result : Success
+ * Date            : 8th Feb 2013
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  first : string,
+  last : string
+}
+
+create type test.Person as
+{
+  name : Name
+}
+
+create type test.TestType as
+{
+  id : int32,
+  name : string,
+  locn : point,
+  zip : string,
+  person : Person
+}
+
+create  table t1(TestType) primary key id;
+
+create  index rtree_index_point  on t1 (locn) type rtree;
+
+create  index rtree_index_point_open  on t1 (open_locn:point) type rtree enforced;
+
+create  index keyWD_indx  on t1 (name) type keyword;
+
+create  index keyWD_indx_open  on t1 (nickname:string) type keyword enforced;
+
+create  index secndIndx  on t1 (zip) type btree;
+
+create  index nested  on t1 (person.name.first) type btree;
+
+create  index secndIndx_open  on t1 (address:string) type btree enforced;
+
+drop index t1.rtree_index_point;
+drop index t1.rtree_index_point_open;
+drop index t1.keyWD_indx;
+drop index t1.keyWD_indx_open;
+drop index t1.secndIndx;
+drop index t1.nested;
+drop index t1.secndIndx_open;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.update.sqlpp
new file mode 100644
index 0000000..e99f055
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.update.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.
+ */
+/*
+ * Description     : Drop empty secondary index.
+ * Expected Result : Success
+ * Date            : 8th Feb 2013
+ *
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.query.sqlpp
new file mode 100644
index 0000000..96e073d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.query.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.
+ */
+/*
+ * Description     : Drop empty secondary index.
+ * Expected Result : Success
+ * Date            : 8th Feb 2013
+ *
+ */
+
+use test;
+
+
+select element l
+from  "Metadata.Index" as l
+where (l.IsPrimary = false)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.1.ddl.sqlpp
new file mode 100644
index 0000000..c4b6af9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.1.ddl.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.
+ */
+/*
+ * Description     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  unique1 : int64,
+  unique2 : int64,
+  two : int64,
+  four : int64,
+  ten : int64,
+  twenty : int64,
+  onePercent : int64,
+  tenPercent : int64,
+  twentyPercent : int64,
+  fiftyPercent : int64,
+  unique3 : int64,
+  evenOnePercent : int64,
+  oddOnePercent : int64,
+  stringu1 : string,
+  stringu2 : string,
+  string4 : string
+}
+
+create  table t1(Schema) primary key unique2;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.2.update.sqlpp
new file mode 100644
index 0000000..77dd0e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+use test;
+
+
+load  table t1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/wisc/onektup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.3.ddl.sqlpp
new file mode 100644
index 0000000..013c209
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.3.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.
+ */
+
+use test;
+
+
+create  index idx_t1_str1  on t1 (stringu1) type btree;
+
+create  index idx_t1_unique1  on t1 (unique1) type btree;
+
+drop index t1.idx_t1_str1;
+drop index t1.idx_t1_unique1;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.4.query.sqlpp
new file mode 100644
index 0000000..53c0cc4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/drop-index/drop-index.4.query.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.
+ */
+/*
+ * Description     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+use test;
+
+
+select element a
+from  t1 as a
+where ((a.unique1 > 10) and (a.stringu1 = 'DGAAAAXXXXXXXXXXXXXXXXXXX'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..a3b6635
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : empty-load-with-index.aql
+ * Description     : Check that an empty load doesn't preclude a future non-empty load on primary and secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  index part_index  on LineItem (l_partkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.2.update.sqlpp
new file mode 100644
index 0000000..4f747ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.2.update.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.
+ */
+/* 
+ * Test case Name  : empty-load-with-index.aql
+ * Description     : Check that an empty load doesn't preclude a future non-empty load on primary and secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/empty.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.3.query.sqlpp
new file mode 100644
index 0000000..218d6f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/empty-load-with-index/empty-load-with-index.3.query.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.
+ */
+/* 
+ * Test case Name  : empty-load-with-index.aql
+ * Description     : Check that an empty load doesn't preclude a future non-empty load on primary and secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+limit 1
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.1.ddl.sqlpp
new file mode 100644
index 0000000..e268958
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.1.ddl.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.
+ */
+/*
+ * Test case Name  : insert-and-scan-dataset-with-index-on-open-field.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index on opened field and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : November 15 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+create type test.Emp as
+{
+  id : int32,
+  lname : string,
+  age : int32,
+  dept : string
+}
+
+create type test.EmpClosed as
+ closed {
+  id : int32,
+  fname : string,
+  lname : string,
+  age : int32,
+  dept : string
+}
+
+create  table test.employee(Emp) primary key id;
+
+create  table test.employeeClosed(EmpClosed) primary key id;
+
+create  index idx_employee_first_name  on test.employee (fname:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.2.update.sqlpp
new file mode 100644
index 0000000..b164aec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : insert-and-scan-dataset-with-index-on-open-field.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index on opened field and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : November 15 2013
+ */
+
+use test;
+
+
+load  table test.employeeClosed using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into test.employee
+select element {'id':x.id,'fname':x.fname,'lname':x.lname,'age':x.age,'dept':x.dept}
+from  "test.employeeClosed" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.3.query.sqlpp
new file mode 100644
index 0000000..a367ab4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index-on-open-field/insert-and-scan-dataset-with-index-on-open-field.3.query.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.
+ */
+/*
+ * Test case Name  : insert-and-scan-dataset-with-index-on-open-field.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index on opened field and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : November 15 2013
+ */
+
+use test;
+
+
+select element l
+from  "test.employee" as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..ea3ac8e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : insert-and-scan-dataset-with-index.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create  table test.employee(Emp) primary key id;
+
+create  index idx_employee_first_name  on test.employee (fname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..7693e6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset-with-index.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+use test;
+
+
+load  table test.employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into test.employee
+select element {'id':(x.id + 10000),'fname':x.fname,'lname':x.lname,'age':x.age,'dept':x.dept}
+from  "test.employee" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.query.sqlpp
new file mode 100644
index 0000000..0b2beca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.query.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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset-with-index.aql
+ * Description     : This test is intended to test inserting into a dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+use test;
+
+
+select element l
+from  "test.employee" as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..9adf95b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.1.ddl.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.
+ */
+/*
+ * Test case Name  : insert-and-scan-dataset.aql
+ * Description     : This test is intended to test inserting into a dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.myDataType as
+{
+  id : int64
+}
+
+create  table myData(myDataType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.2.update.sqlpp
new file mode 100644
index 0000000..2521bd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset.aql
+ * Description     : This test is intended to test inserting into a dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+use test;
+
+
+load  table myData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/odd-numbers.adm"),("format"="adm")) pre-sorted;
+
+insert into myData
+select element {'id':(x.id + 1)}
+from  myData as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.3.query.sqlpp
new file mode 100644
index 0000000..187b469
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.3.query.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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset.aql
+ * Description     : This test is intended to test inserting into a dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+use test;
+
+
+select element c
+from  myData as c
+order by c.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.1.ddl.sqlpp
new file mode 100644
index 0000000..35b7f63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.1.ddl.sqlpp
@@ -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.
+ */
+/*
+ * Test case Name  : insert-and-scan-joined-datasets.aql
+ * Description     : This test is intended to test inserting into a dataset where the incoming stream
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.myDataType as
+{
+  id : int64
+}
+
+create  table myData(myDataType) primary key id;
+
+create  table myData2(myDataType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.2.update.sqlpp
new file mode 100644
index 0000000..53ce110
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-joined-datasets.aql
+ * Description     : This test is intended to test inserting into a dataset where the incoming stream
+
+use test;
+
+
+load  table myData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/odd-numbers.adm"),("format"="adm")) pre-sorted;
+
+load  table myData2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/odd-numbers-2.adm"),("format"="adm")) pre-sorted;
+
+insert into myData
+select element {'id':(x.id + 1)}
+from  myData2 as x,
+      myData as y
+where (x.id = y.id)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.3.query.sqlpp
new file mode 100644
index 0000000..3da5721
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : insert-and-scan-joined-datasets.aql
+ * Description     : This test is intended to test inserting into a dataset where the incoming stream
+
+use test;
+
+
+select element c
+from  myData as c
+order by c.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.1.ddl.sqlpp
new file mode 100644
index 0000000..41999ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.1.ddl.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.
+ */
+
+drop  database STBench if exists;
+create  database STBench;
+
+use STBench;
+
+
+create type STBench.SimpleGeoPlaceType as
+ closed {
+  coordinates : point,
+  id : int64,
+  name : string,
+  tags : string,
+  categories : string,
+  phone : string
+}
+
+create  table SimpleGeoPlace(SimpleGeoPlaceType) primary key id;
+
+create  index btreeName  on SimpleGeoPlace (name) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.2.update.sqlpp
new file mode 100644
index 0000000..a2bc508
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.2.update.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.
+ */
+
+use STBench;
+
+
+insert into SimpleGeoPlace
+select element {'coordinates':STBench.point('-2.423658,53.0842802'),'id':5,'name':'20:20 Mobile','tags':'mobile','categories':'Professional Services Computer Services','phone':''};
+insert into SimpleGeoPlace
+select element {'coordinates':STBench.point('-2.423658,53.0842802'),'id':5,'name':'20:20 Mobile','tags':'mobile','categories':'Professional Services Computer Services','phone':''};
+insert into SimpleGeoPlace
+select element {'coordinates':STBench.point('-2.423658,53.0842802'),'id':5,'name':'20:20 Mobile','tags':'mobile','categories':'Professional Services Computer Services','phone':''};
+insert into SimpleGeoPlace
+select element {'coordinates':STBench.point('-2.423658,53.0842802'),'id':5,'name':'20:20 Mobile','tags':'mobile','categories':'Professional Services Computer Services','phone':''};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.3.ddl.sqlpp
new file mode 100644
index 0000000..111fb09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.3.ddl.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.
+ */
+/* this should successfully drop STBench dataverse */
+
+drop  database STBench;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..7377226
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : insert-into-empty-dataset-with-index.aql
+ * Description     : Check that we can insert into an empty dataset and its empty secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
+create  index idx_LineID_partkey  on LineID (l_linenumber) type btree;
+
+create  index idx_LineID_suppkey  on LineID (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..70b9d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.update.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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset-with-index.aql
+ * Description     : Check that we can insert into an empty dataset and its empty secondary indexes 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+insert into LineID
+{'l_orderkey':1,'l_linenumber':2,'l_suppkey':3};
+insert into LineID
+{'l_orderkey':2,'l_linenumber':3,'l_suppkey':4};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.query.sqlpp
new file mode 100644
index 0000000..5d8e160
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.query.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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset-with-index.aql
+ * Description     : Check that we can insert into an empty dataset and its empty secondary indexes 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+select element c
+from  LineID as c
+where ((c.l_suppkey < 100) and (c.l_linenumber < 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..05562de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : insert-into-empty-dataset.aql
+ * Description     : Check that we can insert into an empty dataset
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.2.update.sqlpp
new file mode 100644
index 0000000..5994044
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.2.update.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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset.aql
+ * Description     : Check that we can insert into an empty dataset 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+insert into LineID
+{'l_orderkey':1,'l_linenumber':2,'l_suppkey':3};
+insert into LineID
+{'l_orderkey':2,'l_linenumber':3,'l_suppkey':4};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.3.query.sqlpp
new file mode 100644
index 0000000..2dd4c1d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.3.query.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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset.aql
+ * Description     : Check that we can insert into an empty dataset 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+select element c
+from  LineID as c
+where ((c.l_suppkey < 100) and (c.l_linenumber < 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ddl.sqlpp
new file mode 100644
index 0000000..7fccebc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.update.sqlpp
new file mode 100644
index 0000000..478545c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.update.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;
+
+
+load  table LineID using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ddl.sqlpp
new file mode 100644
index 0000000..ec12e33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineID_partkey  on LineID (l_linenumber) type btree;
+
+create  index idx_LineID_suppkey  on LineID (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.update.sqlpp
new file mode 100644
index 0000000..6600a88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.update.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.
+ */
+
+use test;
+
+
+insert into LineID
+{'l_orderkey':1,'l_linenumber':2,'l_suppkey':3};
+insert into LineID
+{'l_orderkey':2,'l_linenumber':3,'l_suppkey':4};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.query.sqlpp
new file mode 100644
index 0000000..2ed4653
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineID as c
+where ((c.l_suppkey = 3) and (c.l_linenumber = 2))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ddl.sqlpp
new file mode 100644
index 0000000..09ed9a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.update.sqlpp
new file mode 100644
index 0000000..a64c6f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table LineID using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ddl.sqlpp
new file mode 100644
index 0000000..ec12e33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineID_partkey  on LineID (l_linenumber) type btree;
+
+create  index idx_LineID_suppkey  on LineID (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.update.sqlpp
new file mode 100644
index 0000000..250ad68
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+insert into LineID
+select element {'l_orderkey':l.l_orderkey,'l_linenumber':l.l_linenumber,'l_suppkey':l.l_partkey}
+from  LineItem as l
+where (l.l_orderkey < 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.query.sqlpp
new file mode 100644
index 0000000..bbc0951
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineID as c
+where ((c.l_suppkey < 100) and (c.l_linenumber < 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.1.ddl.sqlpp
new file mode 100644
index 0000000..7fccebc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.2.update.sqlpp
new file mode 100644
index 0000000..c6e4fa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.2.update.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.
+ */
+
+use test;
+
+
+load  table LineID using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineID
+{'l_orderkey':1,'l_linenumber':2,'l_suppkey':3};
+insert into LineID
+{'l_orderkey':2,'l_linenumber':3,'l_suppkey':4};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.3.query.sqlpp
new file mode 100644
index 0000000..bbc0951
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineID as c
+where ((c.l_suppkey < 100) and (c.l_linenumber < 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cd61d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  unique1 : int64,
+  unique2 : int64,
+  two : int64,
+  four : int64,
+  ten : int64,
+  twenty : int64,
+  onePercent : int64,
+  tenPercent : int64,
+  twentyPercent : int64,
+  fiftyPercent : int64,
+  unique3 : int64,
+  evenOnePercent : int64,
+  oddOnePercent : int64,
+  stringu1 : string,
+  stringu2 : string,
+  string4 : string
+}
+
+create  table onektup(Schema) primary key unique2;
+
+create  table tenktup1(Schema) primary key unique2;
+
+create  table tmp(Schema) primary key unique2;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.2.update.sqlpp
new file mode 100644
index 0000000..43ce40c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.2.update.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.
+ */
+
+use test;
+
+
+load  table onektup using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/wisc/onektup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table tenktup1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/wisc/tenktup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/wisc/empty.adm"),("format"="adm")) pre-sorted;
+
+insert into tmp
+select element l
+from  tenktup1 as l
+where ((l.unique2 > 0) and (l.unique2 < 99))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.3.query.sqlpp
new file mode 100644
index 0000000..efd28ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.3.query.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.
+ */
+
+use test;
+
+
+select element t
+from  tmp as t
+order by t.unique2
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.1.ddl.sqlpp
new file mode 100644
index 0000000..db7f984
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset.aql
+ * Description     : Check that we can insert into an empty dataset 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int32,
+  l_linenumber : int32,
+  l_suppkey : int32
+}
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
+create  table LineID2(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.2.update.sqlpp
new file mode 100644
index 0000000..b47a65c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset.aql
+ * Description     : Check that we can insert into an empty dataset 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+insert into LineID
+{'l_orderkey':1,'l_linenumber':2,'l_suppkey':3};
+insert into LineID
+{'l_orderkey':2,'l_linenumber':3,'l_suppkey':4};
+insert into LineID2
+select element test."flow-record"(x)
+from  LineID as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.3.query.sqlpp
new file mode 100644
index 0000000..3328f0d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-record-function/insert-record-function.3.query.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.
+ */
+/* 
+ * Test case Name  : insert-into-empty-dataset.aql
+ * Description     : Check that we can insert into an empty dataset 
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use test;
+
+
+select element c
+from  LineID2 as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.1.ddl.sqlpp
new file mode 100644
index 0000000..28f43ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.1.ddl.sqlpp
@@ -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     : Insert from source dataset into target dataset
+ * Expected Result : Success
+ * Date            : 25th July 2012
+ * Issue #         : Issue 76
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+ closed {
+  id : string,
+  name : string?
+}
+
+create type testdv2.testtype02 as
+ closed {
+  id : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.2.update.sqlpp
new file mode 100644
index 0000000..1e94f38
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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     : Insert from source dataset into target dataset
+ * Expected Result : Success
+ * Date            : 25th July 2012
+ * Issue #         : Issue 76
+ */
+
+use testdv2;
+
+
+insert into testds01
+select element {'id':'001'};
+insert into testds01
+select element {'id':'002','name':'John Doe'};
+insert into testds02
+select element {'id':'003'};
+insert into testds02
+select element {'id':'004'};
+insert into testds02
+select element {'id':'005'};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.3.query.sqlpp
new file mode 100644
index 0000000..64f96ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.3.query.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.
+ */
+/*
+ * Description     : Insert from source dataset into target dataset
+ * Expected Result : Success
+ * Date            : 25th July 2012
+ * Issue #         : Issue 76
+ */
+
+use testdv2;
+
+
+select element d
+from  testds01 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax.sqlpp
new file mode 100644
index 0000000..7235381
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax.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.
+ */
+/* 
+ * Test case Name  : insert-syntax-change.aql
+ * Description     : verify various AQL syntax for insert
+ * Expected Result : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  id : int32,
+  name : string
+}
+
+create  table testds(testtype) primary key id;
+
+insert into testds
+select element {'id':1,'name':'Person One','hobbies':{{'Rock','Metal'}}};
+insert into testds
+select element {'id':2,'name':'Person Two','hobbies':{{'Rock','Jazz'}}};
+insert into testds
+select element {'id':3,'name':'Person Three','hobbies':{{'Blues'}}};
+insert into testds
+select element {'id':4,'name':'Person Four','hobbies':{{'Metal','Jazz'}}};
+write output to nc1:"rttest/dml_insert-syntax.adm"
+select element d
+from  testds as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.1.ddl.sqlpp
new file mode 100644
index 0000000..b227ff7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.1.ddl.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.
+ */
+/*
+ * Test case Name  : insert-syntax-change.aql
+ * Description     : verify various AQL syntax for insert
+ * Expected Result : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  id : int64,
+  name : string
+}
+
+create  table testds(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.2.update.sqlpp
new file mode 100644
index 0000000..fdf288c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.2.update.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.
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':1,'name':'Person One','hobbies':{{'Rock','Metal'}}};
+insert into testds
+select element {'id':2,'name':'Person Two','hobbies':{{'Rock','Jazz'}}};
+insert into testds
+select element {'id':3,'name':'Person Three','hobbies':{{'Blues'}}};
+insert into testds
+select element {'id':4,'name':'Person Four','hobbies':{{'Metal','Jazz'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.3.query.sqlpp
new file mode 100644
index 0000000..e286d9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-syntax/insert-syntax.3.query.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.
+ */
+
+use testdv2;
+
+
+select element d
+from  testds as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.1.ddl.sqlpp
new file mode 100644
index 0000000..3dad99f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.2.update.sqlpp
new file mode 100644
index 0000000..57f10bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.2.update.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;
+
+
+insert into DBLP
+select element {'dblpid':'books/acm/kim95/Blakeley95','title':'OQL[C++]  Extending C++ with an Object Query Capability.','authors':'José A. Blakeley','misc':'2002-01-03 69-88 Modern Database Systems db/books/collections/kim95.html#Blakeley95 1995'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.3.query.sqlpp
new file mode 100644
index 0000000..34a900c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Extending')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.1.ddl.sqlpp
new file mode 100644
index 0000000..3dad99f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.2.update.sqlpp
new file mode 100644
index 0000000..561a583
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.2.update.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;
+
+
+insert into DBLP
+select element {'id':'89fb1567-70f8-4e59-87d9-ace64f73daf1','dblpid':'books/acm/kim95/Blakeley95','title':'OQL[C++]  Extending C++ with an Object Query Capability.','authors':'José A. Blakeley','misc':'2002-01-03 69-88 Modern Database Systems db/books/collections/kim95.html#Blakeley95 1995'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.3.query.sqlpp
new file mode 100644
index 0000000..34a900c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Extending')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.1.ddl.sqlpp
new file mode 100644
index 0000000..8a6f8bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.2.update.sqlpp
new file mode 100644
index 0000000..9ed95c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.2.update.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;
+
+
+insert into DBLP
+select element {'id':test.uuid('89fb1567-70f8-4e59-87d9-ace64f73daf1'),'dblpid':'books/acm/kim95/Blakeley95','title':'OQL[C++]  Extending C++ with an Object Query Capability.','authors':'José A. Blakeley','misc':'2002-01-03 69-88 Modern Database Systems db/books/collections/kim95.html#Blakeley95 1995'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.3.query.sqlpp
new file mode 100644
index 0000000..861081c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.3.query.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.
+ */
+
+use test;
+
+
+select element o
+from  DBLP as o
+where test.contains(o.title,'Extending')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.1.ddl.sqlpp
new file mode 100644
index 0000000..09ed9a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.2.update.sqlpp
new file mode 100644
index 0000000..0d5dd63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table LineID using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineID
+select element {'l_orderkey':l.l_orderkey,'l_linenumber':l.l_linenumber,'l_suppkey':l.l_partkey}
+from  LineItem as l
+where (l.l_orderkey < 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.3.query.sqlpp
new file mode 100644
index 0000000..b4d0ce2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert/insert.3.query.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.
+ */
+
+use test;
+
+
+select element c
+from  LineID as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.1.ddl.sqlpp
new file mode 100644
index 0000000..09ed9a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.2.update.sqlpp
new file mode 100644
index 0000000..1e4cf46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table LineID using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineID
+select element {'l_orderkey':l.l_orderkey,'l_linenumber':l.l_linenumber,'l_suppkey':l.l_partkey}
+from  LineItem as l
+where (l.l_orderkey < 1000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.3.query.sqlpp
new file mode 100644
index 0000000..b4d0ce2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_less_nc/insert_less_nc.3.query.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.
+ */
+
+use test;
+
+
+select element c
+from  LineID as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.1.ddl.sqlpp
new file mode 100644
index 0000000..9ec80cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.2.update.sqlpp
new file mode 100644
index 0000000..dd9eacb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.HDFSAdapter" (("hdfs"="hdfs://localhost:10009"),("path"="/tpch/lineitem.tbl"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.3.query.sqlpp
new file mode 100644
index 0000000..5016728
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-from-hdfs/load-from-hdfs.3.query.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.
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.1.ddl.sqlpp
new file mode 100644
index 0000000..3dad99f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.2.update.sqlpp
new file mode 100644
index 0000000..1854b58
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.2.update.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;
+
+
+load  table DBLP using "localfs" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.3.query.sqlpp
new file mode 100644
index 0000000..a9bdf65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Authorization in Object-Oriented Databases.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.1.ddl.sqlpp
new file mode 100644
index 0000000..3dad99f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.2.update.sqlpp
new file mode 100644
index 0000000..2ecbe5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.2.update.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;
+
+
+load  table DBLP using "localfs" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk_including_uuid.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.3.query.sqlpp
new file mode 100644
index 0000000..a9bdf65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Authorization in Object-Oriented Databases.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.1.ddl.sqlpp
new file mode 100644
index 0000000..e56944a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  dblpid : string,
+  id : uuid,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.2.update.sqlpp
new file mode 100644
index 0000000..2ecbe5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.2.update.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;
+
+
+load  table DBLP using "localfs" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk_including_uuid.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.3.query.sqlpp
new file mode 100644
index 0000000..a9bdf65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Authorization in Object-Oriented Databases.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.1.ddl.sqlpp
new file mode 100644
index 0000000..8a6f8bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.2.update.sqlpp
new file mode 100644
index 0000000..2ecbe5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.2.update.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;
+
+
+load  table DBLP using "localfs" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk_including_uuid.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.3.query.sqlpp
new file mode 100644
index 0000000..a9bdf65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Authorization in Object-Oriented Databases.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.1.ddl.sqlpp
new file mode 100644
index 0000000..3d72645
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  title : string,
+  authors : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.2.update.sqlpp
new file mode 100644
index 0000000..2cca0e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.2.update.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;
+
+
+load  table DBLP using "localfs" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk.csv"),("format"="delimited-text"),("delimiter"=","));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.3.query.sqlpp
new file mode 100644
index 0000000..a9bdf65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Authorization in Object-Oriented Databases.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.1.ddl.sqlpp
new file mode 100644
index 0000000..3d72645
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  title : string,
+  authors : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.2.update.sqlpp
new file mode 100644
index 0000000..5b07616
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.2.update.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;
+
+
+load  table DBLP using "localfs" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk_including_uuid.csv"),("format"="delimited-text"),("delimiter"=","));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.3.query.sqlpp
new file mode 100644
index 0000000..a9bdf65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Authorization in Object-Oriented Databases.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.1.ddl.sqlpp
new file mode 100644
index 0000000..3d72645
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : uuid,
+  title : string,
+  authors : string
+}
+
+create  table DBLP(DBLPType) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.2.update.sqlpp
new file mode 100644
index 0000000..25cb2c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id-autogenerated-pk.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.3.query.sqlpp
new file mode 100644
index 0000000..dfd8953
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.3.query.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.
+ */
+
+use test;
+
+
+select element o.title
+from  DBLP as o
+where test.contains(o.title,'Physical Object Management.')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..d1c87bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemTypeOpen as
+{
+  l_orderkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItemOpen(LineItemTypeOpen) primary key l_orderkey,l_linenumber;
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  index idx_partkey_open  on LineItemOpen (l_partkey:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.2.update.sqlpp
new file mode 100644
index 0000000..1cd1694
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into test.LineItemOpen
+select element x
+from  "test.LineItem" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.3.query.sqlpp
new file mode 100644
index 0000000..abe4c53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index-open/load-with-index-open.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItemOpen as c
+where (c.l_partkey = 100)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..4aa94a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  index idx_partkey  on LineItem (l_partkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.3.query.sqlpp
new file mode 100644
index 0000000..76ea706
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-index/load-with-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_partkey = 100)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..d8db955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPTypeOpen as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPTypeOpen) primary key id;
+
+create  index ngram_index_open  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.2.update.sqlpp
new file mode 100644
index 0000000..5b9cd36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.3.query.sqlpp
new file mode 100644
index 0000000..4a2da41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLPOpen as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.1.ddl.sqlpp
new file mode 100644
index 0000000..1797b2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLP1(DBLPType) primary key id;
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+create  index ngram_index1  on DBLP1 (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.3.query.sqlpp
new file mode 100644
index 0000000..0ac4ba6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..0259145
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  table MyDataOpen(MyRecordOpen) primary key id;
+
+create  index rtree_index_point  on MyDataOpen (point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.2.update.sqlpp
new file mode 100644
index 0000000..e3ce7fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.2.update.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.
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into test.MyDataOpen
+select element x
+from  "test.MyData" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.3.query.sqlpp
new file mode 100644
index 0000000..77986b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyDataOpen as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..eb1639f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..c0b15a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.2.update.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;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..7240752
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..597375c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPTypeOpen as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPTypeOpen) primary key id;
+
+create  index keyword_index  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.2.update.sqlpp
new file mode 100644
index 0000000..5b9cd36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.3.query.sqlpp
new file mode 100644
index 0000000..e364901
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLPOpen as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.1.ddl.sqlpp
new file mode 100644
index 0000000..3894872
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLP1(DBLPType) primary key id;
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+create  index keyword_index1  on DBLP1 (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.3.query.sqlpp
new file mode 100644
index 0000000..257e5d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/load-with-word-index/load-with-word-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.sqlpp
new file mode 100644
index 0000000..a31bc2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.AddressType as
+{
+  street : string,
+  city : string
+}
+
+create type testdv2.Dept as
+{
+  name : string,
+  id : int64
+}
+
+create type testdv2.testtype as
+ closed {
+  name : string,
+  id : string,
+  address : AddressType?,
+  department : {{Dept}}?
+}
+
+create type testdv2.testtype2 as
+{
+  name : string,
+  id : string
+}
+
+create  table testds(testtype) primary key id;
+
+create  table testds2(testtype2) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.sqlpp
new file mode 100644
index 0000000..cce9137
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.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.
+ */
+/* 
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','name':'Person One','address':{'street':'3019 DBH','city':'Irvine','zip':92697},'department':{{{'name':'CS','id':299,'review':5},{'name':'EE','id':399}}}};
+insert into testds
+select element {'id':'002','name':'Person Two'};
+insert into testds
+select element {'id':'003','name':'Person Three','address':{'street':'2019 DBH','city':'Irvine'}};
+insert into testds
+select element {'id':'004','name':'Person Four','address':{'street':'1019 DBH','city':'irvine','property':{'zip':92697,'review':'positive'}}};
+insert into testds2
+select element d
+from  testds as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.sqlpp
new file mode 100644
index 0000000..cc9c002
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.1.ddl.sqlpp
new file mode 100644
index 0000000..a04432b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.1.ddl.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.
+ */
+/* 
+ * Test case Name  : opentype-c2o.aql
+ * Description     : read data from a closed type dataset into a open type dataset and verify if
+ *					records can be casted to the target open type 
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+ closed {
+  id : string,
+  name : string,
+  hobby : {{string}}?
+}
+
+create type testdv2.testtype2 as
+{
+  id : string
+}
+
+create  table testds(testtype) primary key id;
+
+create  table testds2(testtype2) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.2.update.sqlpp
new file mode 100644
index 0000000..4701e1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-c2o.aql
+ * Description     : read data from a closed type dataset into a open type dataset and verify if
+ *					records can be casted to the target open type 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'hobby':{{'music','coding'}},'id':'001','name':'Person Three'};
+insert into testds
+select element {'name':'Person One','id':'002','hobby':{{'sports'}}};
+insert into testds
+select element {'id':'003','hobby':{{'movie','sports'}},'name':'Person Two'};
+insert into testds
+select element {'id':'004','name':'Person Four','hobby':{{'swimming'}}};
+insert into testds
+select element {'name':'Person Five','id':'005'};
+insert into testds2
+select element d
+from  testds as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.3.query.sqlpp
new file mode 100644
index 0000000..6d866d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-c2o/opentype-c2o.3.query.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.
+ */
+/* 
+ * Test case Name  : opentype-c2o.aql
+ * Description     : read data from a closed type dataset into a open type dataset and verify if
+ *					records can be casted to the target open type 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.sqlpp
new file mode 100644
index 0000000..3ffd615
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-closed-optional.aql
+ * Description     : verify that closed type can have optional fields
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+ closed {
+  name : string?,
+  id : string
+}
+
+create  table testds(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.2.update.sqlpp
new file mode 100644
index 0000000..e9b729d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-closed-optional.aql
+ * Description     : verify that closed type can have optional fields
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','name':'Person One'};
+insert into testds
+select element {'id':'002'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.3.query.sqlpp
new file mode 100644
index 0000000..4f9549f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-closed-optional.aql
+ * Description     : verify that closed type can have optional fields
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.1.ddl.sqlpp
new file mode 100644
index 0000000..5a2e187
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-insert.aql
+ * Description     : verify static type casting
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  id : string,
+  name : string
+}
+
+create  table testds(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.2.update.sqlpp
new file mode 100644
index 0000000..228bf21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.2.update.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.
+ */
+/* 
+ * Test case Name  : opentype-insert.aql
+ * Description     : verify static type casting
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','name':'Person Three','hobbies':{{'scuba','music'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.3.query.sqlpp
new file mode 100644
index 0000000..de3ca47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert/opentype-insert.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-insert.aql
+ * Description     : verify static type casting
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.1.ddl.sqlpp
new file mode 100644
index 0000000..e00d8f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : opentype-insert2.aql
+ * Description     : verify that the case where SetClosedRecordRule should not rewrite
+ *					the plan to use closed-record-descriptor
+ * Expected Result : Success
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int64
+}
+
+create  table testds(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.2.update.sqlpp
new file mode 100644
index 0000000..a14aabd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.2.update.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.
+ */
+/* 
+ * Test case Name  : opentype-insert2.aql
+ * Description     : verify that the case where SetClosedRecordRule should not rewrite
+ *					the plan to use closed-record-descriptor
+ * Expected Result : Success
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':i,'name':'John Doe'}
+from  test.range(1,10) as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.3.query.sqlpp
new file mode 100644
index 0000000..6ab6da5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-insert2/opentype-insert2.3.query.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.
+ */
+/* 
+ * Test case Name  : opentype-insert2.aql
+ * Description     : verify that the case where SetClosedRecordRule should not rewrite
+ *					the plan to use closed-record-descriptor
+ * Expected Result : Success
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.1.ddl.sqlpp
new file mode 100644
index 0000000..93322c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.1.ddl.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.
+ */
+/* 
+ * Test case Name  : opentype-noexpand.aql
+ * Description     : verify that open type dataset can have records without open fields
+ *					 verify the bag-based fields
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  name : string?,
+  id : string
+}
+
+create  table testds(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.2.update.sqlpp
new file mode 100644
index 0000000..00883d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.2.update.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.
+ */
+/* 
+ * Test case Name  : opentype-noexpand.aql
+ * Description     : verify that open type dataset can have records without open fields
+ *					 verify the bag-based fields
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','name':'Person One'};
+insert into testds
+select element {'id':'002'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.3.query.sqlpp
new file mode 100644
index 0000000..18d610e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-noexpand/opentype-noexpand.3.query.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.
+ */
+/* 
+ * Test case Name  : opentype-noexpand.aql
+ * Description     : verify that open type dataset can have records without open fields
+ *					 verify the bag-based fields
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.sqlpp
new file mode 100644
index 0000000..d10f0f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.AddressType as
+{
+  street : string,
+  city : string
+}
+
+create type testdv2.Dept as
+ closed {
+  name : string,
+  id : int64
+}
+
+create type testdv2.testtype as
+{
+  name : string,
+  id : string
+}
+
+create type testdv2.testtype2 as
+ closed {
+  name : string,
+  id : string,
+  address : AddressType?,
+  department : {{Dept}}?
+}
+
+create  table testds(testtype) primary key id;
+
+create  table testds2(testtype2) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.sqlpp
new file mode 100644
index 0000000..aa032a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.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.
+ */
+/* 
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','name':'Person One','address':{'street':'3019 DBH','city':'Irvine','zip':92697},'department':{{{'name':'CS','id':299},{'name':'EE','id':399}}}};
+insert into testds
+select element {'id':'002','name':'Person Two'};
+insert into testds
+select element {'id':'003','name':'Person Three','address':{'street':'2019 DBH','city':'Irvine'}};
+insert into testds
+select element {'id':'004','name':'Person Four','address':{'street':'1019 DBH','city':'irvine','property':{'zip':92697,'review':'positive'}}};
+insert into testds2
+select element d
+from  testds as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.sqlpp
new file mode 100644
index 0000000..cc9c002
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.1.ddl.sqlpp
new file mode 100644
index 0000000..6e52c42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-o2c.aql
+ * Description     : verify that open records can be inserted into a closed dataset
+ *					 verify missing optional fields in the closed part of the target closed dataset are allowed
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  id : string,
+  name : string
+}
+
+create type testdv2.testtype2 as
+ closed {
+  hobby : {{string}}?,
+  id : string,
+  name : string
+}
+
+create  table testds(testtype) primary key id;
+
+create  table testds2(testtype2) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.2.update.sqlpp
new file mode 100644
index 0000000..7c3acfd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-o2c.aql
+ * Description     : verify that open records can be inserted into a closed dataset
+ *					 verify missing optional fields in the closed part of the target closed dataset are allowed
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','hobby':{{'music'}},'name':'Person Three'};
+insert into testds
+select element {'id':'002','name':'Person Three','hobby':{{'football'}}};
+insert into testds
+select element {'id':'003','name':'Person Three','hobby':{{'movie','coding','debugging'}}};
+insert into testds
+select element {'name':'Person Three','hobby':{{'swimming','music'}},'id':'004'};
+insert into testds
+select element {'id':'005','name':'Person Five'};
+insert into testds2
+select element d
+from  testds as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.3.query.sqlpp
new file mode 100644
index 0000000..e7de109
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2c/opentype-o2c.3.query.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.
+ */
+/* 
+ * Test case Name  : opentype-o2c.aql
+ * Description     : verify that open records can be inserted into a closed dataset
+ *					 verify missing optional fields in the closed part of the target closed dataset are allowed
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.1.ddl.sqlpp
new file mode 100644
index 0000000..a233576
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-o2o.aql
+ * Description     : verify that the dynamic type cast from one open type to another compatible open type
+ *					 verify the bag-based fields
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  name : string,
+  id : string
+}
+
+create type testdv2.testtype2 as
+{
+  id : string,
+  name : string,
+  hobby : string
+}
+
+create  table testds(testtype) primary key id;
+
+create  table testds2(testtype2) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.2.update.sqlpp
new file mode 100644
index 0000000..b915417
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : opentype-o2o.aql
+ * Description     : verify that the dynamic type cast from one open type to another compatible open type
+ *					 verify the bag-based fields
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'name':'Person One','id':'001','hobby':'music'};
+insert into testds
+select element {'hobby':'football','city':'irvine','name':'Person Two','id':'002'};
+insert into testds
+select element {'name':'Person Three','id':'003','hobby':'movie'};
+insert into testds
+select element {'hobby':'swimming','name':'Person Four','id':'004','phone':'102-304-506'};
+insert into testds2
+select element d
+from  testds as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.3.query.sqlpp
new file mode 100644
index 0000000..314bd1f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/opentype-o2o/opentype-o2o.3.query.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.
+ */
+/* 
+ * Test case Name  : opentype-o2o.aql
+ * Description     : verify that the dynamic type cast from one open type to another compatible open type
+ *					 verify the bag-based fields
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.1.ddl.sqlpp
new file mode 100644
index 0000000..f9ccca6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : This test case is to verify the fix for issue205
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmployeeStat as
+{
+  age : int64,
+  salary : int64
+}
+
+create type test.EmployeeType as
+ closed {
+  id : string,
+  stat : EmployeeStat,
+  deptCode : int64
+}
+
+create  table Employees(EmployeeType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.2.update.sqlpp
new file mode 100644
index 0000000..34639d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue205
+
+use test;
+
+
+insert into Employees
+select element {'id':'1234','stat':{'age':50,'salary':120000},'deptCode':32};
+insert into Employees
+select element {'id':'5678','stat':{'age':40,'salary':100000},'deptCode':16};
+delete l from Employees
+ where (l.id = '1234');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.3.query.sqlpp
new file mode 100644
index 0000000..0afeb12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue205/query-issue205.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue205
+
+use test;
+
+
+select element l
+from  Employees as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.1.ddl.sqlpp
new file mode 100644
index 0000000..dd263f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue288
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineIDType as
+ closed {
+  l_orderkey : int64,
+  l_linenumber : int64,
+  l_suppkey : int64
+}
+
+create  table LineID(LineIDType) primary key l_orderkey,l_linenumber;
+
+create  table LineID2(LineIDType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.2.update.sqlpp
new file mode 100644
index 0000000..8a6b5c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.2.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+
+use test;
+
+
+load  table LineID using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineID
+{'l_orderkey':1,'l_linenumber':2,'l_suppkey':3};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.3.ddl.sqlpp
new file mode 100644
index 0000000..3ba2ebc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.3.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+
+use test;
+
+
+create  index idx_LineID_1  on LineID (l_linenumber) type btree;
+
+create  index idx_LineID_2  on LineID2 (l_linenumber) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.4.update.sqlpp
new file mode 100644
index 0000000..90b32fa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.4.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+
+use test;
+
+
+insert into LineID2
+select element r
+from  LineID as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.5.query.sqlpp
new file mode 100644
index 0000000..1c874d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue288/query-issue288.5.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+
+use test;
+
+
+select element c
+from  LineID2 as c
+where (c.l_linenumber = 2)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.1.ddl.sqlpp
new file mode 100644
index 0000000..8c08c96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.1.ddl.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.
+ */
+
+create  database SocialNetworkData;
+
+use SocialNetworkData;
+
+
+create type SocialNetworkData.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type SocialNetworkData.FacebookUserType as
+ closed {
+  id : int64,
+  "id-copy" : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table HandbookUsers(FacebookUserType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.2.update.sqlpp
new file mode 100644
index 0000000..ab19ec5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.2.update.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.
+ */
+
+use SocialNetworkData;
+
+
+load  table FacebookUsers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/fbu-dml-insert-shuffled.adm"),("format"="adm"));
+
+insert into HandbookUsers
+select element x
+from  FacebookUsers as x
+where (x.id < 10307032)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.3.query.sqlpp
new file mode 100644
index 0000000..a471812
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue382/query-issue382.3.query.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.
+ */
+
+use SocialNetworkData;
+
+
+select element SocialNetworkData.count((
+    select element h
+    from  HandbookUsers as h
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.1.ddl.sqlpp
new file mode 100644
index 0000000..c459a1b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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  : This test case is to verify the fix for issue433
+
+create  database insertIssue;
+
+use insertIssue;
+
+
+create type insertIssue.subElem as
+ closed {
+  n : string,
+  e : int64?
+}
+
+create type insertIssue.elem as
+ closed {
+  id : int64,
+  name : string,
+  sub : [subElem]
+}
+
+create  table myDataset(elem) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.2.update.sqlpp
new file mode 100644
index 0000000..2e1fa3c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.2.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue433
+
+use insertIssue;
+
+
+insert into myDataset
+select element t
+from  [{'id':1,'name':'u1','sub':[{'n':'se1','e':100}]},{'id':2,'name':'u2','sub':[{'n':'se2','e':200}]}] as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.3.query.sqlpp
new file mode 100644
index 0000000..b3e659a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/query-issue433/query-issue433.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue433
+
+use insertIssue;
+
+
+select element d
+from  myDataset as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..3518af6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..2dfbed0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..8934610
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ddl.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;
+
+
+create  index age_index  on Customers (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..0b60e5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.update.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;
+
+
+delete c from Customers
+ where (c.cid >= 200);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..9a1af15
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element c
+from  Customers as c
+where (c.age < 20)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..bd313ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.1.ddl.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : scan-delete-btree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on open fields 
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerOpenType as
+{
+  cid : int64,
+  name : string,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table CustomersOpen(CustomerOpenType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..e6e9e12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on open fields
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+insert into test.CustomersOpen
+select element {'cid':x.cid,'name':x.name,'age':x.age,'address':x.address,'interests':x.interests,'children':x.children}
+from  "test.Customers" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..7f3e371
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.3.ddl.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;
+
+
+create  index age_index  on CustomersOpen (age:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..26005e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.4.update.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;
+
+
+delete c from CustomersOpen
+ where (c.cid >= 200);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..083cc98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-btree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on open fields 
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+select element c
+from  CustomersOpen as c
+where (c.age < 20)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..c55ea58
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..c0062cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..9d3626a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..9a7d266
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.id > 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..814987d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..2f7b6ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.1.ddl.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..fddb746
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..c708608
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..dd73b8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+delete o from DBLPOpen
+ where (o.id > 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..48cb4f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+select element o
+from  DBLPOpen as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..1eb28dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..b8dadec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..e0e85b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..6381e04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.id > 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..1b01521
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..1a19334
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..573d7f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..32abe5b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..eae0a3a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.id < 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..c271ba0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..f68dd52
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.1.ddl.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..91b1f49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..e8d46d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..f601add
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+delete o from DBLPOpen
+ where (o.id < 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..af69f18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+select element o
+from  DBLPOpen as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..6dd2b90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..e0d1fca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..92bb54c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..2722743
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.id < 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..6767607
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..0da3057
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point?,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..9a67722
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary rtree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..662b250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..7d4cf25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.update.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;
+
+
+delete m from MyData
+ where (m.id > 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..74707da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary rtree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..b7057ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.1.ddl.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  table MyDataOpen(MyRecordOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..1112336
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into test.MyDataOpen
+select element x
+from  "test.MyData" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..13d1312
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+create  index rtree_index_point  on MyDataOpen (point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..136519e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+delete m from MyDataOpen
+ where (m.id > 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..3a4842e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test deletion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : March 13 2014
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyDataOpen as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..52704f2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..c0b15a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.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;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..662b250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..7d4cf25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.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;
+
+
+delete m from MyData
+ where (m.id > 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..7240752
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..0c33371
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table CustomersMini(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..726dd24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..57ef7ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ddl.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;
+
+
+create  index age_index  on CustomersMini (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..0c60d82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+insert into CustomersMini
+select element {'cid':c.cid,'name':c.name,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}
+from  Customers as c
+where (c.cid < 200)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..edeb1c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element c
+from  CustomersMini as c
+where (c.age < 20)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..354e6ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.1.ddl.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on open fields
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerOpenType as
+{
+  cid : int64,
+  name : string,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table CustomersOpen(CustomerOpenType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..5b50cf8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on open fields
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..7f3e371
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.3.ddl.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;
+
+
+create  index age_index  on CustomersOpen (age:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..f661962
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.4.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+insert into CustomersOpen
+select element {'cid':c.cid,'name':c.name,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}
+from  Customers as c
+where (c.cid < 200)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..0726d05
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on open fields
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+select element c
+from  CustomersOpen as c
+where (c.age < 20)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..a8187ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLP1(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..a52e7f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..866e2a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ddl.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+create  index ngram_index1  on DBLP1 (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..1d23b8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP1
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..5d5608d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP1 as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..e9c5d5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.1.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..2983fc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..9a87a57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+create  index ngram_index1  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..32a482e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+insert into DBLPOpen
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..11754fa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+select element o
+from  DBLPOpen as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..013819a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLP1(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..f7f3e39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..7afb639
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ddl.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
+create  index ngram_index1  on DBLP1 (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..01ad425
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP1
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..c8305e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP1 as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..247ffba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLP1(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..39b7745
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..7ad7925
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ddl.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+create  index keyword_index1  on DBLP1 (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..724cd44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP1
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLP as o
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..072b732
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.  
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP1 as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..8223f88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.1.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..3b028d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..8ce9d0f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+create  index keyword_index1  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..1eb85d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+insert into DBLPOpen
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLP as o
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..1d61ba9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+select element o
+from  DBLPOpen as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..ccc58f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLP1(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..7b57aa7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..16cf7fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ddl.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
+create  index keyword_index1  on DBLP1 (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..dfd8db8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP1
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLP as o
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..c0e90f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index. 
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o
+from  DBLP1 as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..dc93a93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point?,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyMiniRecord as
+ closed {
+  id : int64,
+  point : point?
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..992eab2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary rtree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..aa605e2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ddl.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.
+ */
+
+use test;
+
+
+create  table MyMiniData(MyMiniRecord) primary key id;
+
+create  index rtree_index_point  on MyMiniData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..7a43c93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.update.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.
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'id':m.id,'point':m.point}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..6b0e051
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.query.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.
+ */
+/* 
+ * Test case Name  : scan-insert-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary rtree indexes that are built on nullable fields 
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..469993f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.1.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyOpenRecord as
+{
+  id : int64
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  table MyOpenData(MyOpenRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..b4c87a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.2.update.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.
+ */
+/* 
+ * Test case Name  : scan-insert-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary rtree index that is built on open field. 
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..077cf51
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+create  index rtree_index_point_0  on MyData (point) type rtree;
+
+create  index rtree_index_point  on MyOpenData (point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.4.update.sqlpp
new file mode 100644
index 0000000..9df6e54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+insert into MyOpenData
+select element {'id':m.id,'point':m.point}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.5.query.sqlpp
new file mode 100644
index 0000000..bcd00b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-open.aql
+ * Description     : This test is intended to test insertion from secondary rtree index that is built on open field.
+ * Expected Result : Success
+ * Date            : Feb 13 2014
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyOpenData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..82c60421
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyMiniRecord as
+ closed {
+  id : int64,
+  point : point
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  table MyMiniData(MyMiniRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..13f164c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.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.
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyMiniData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..ba72d94
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.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.
+ */
+
+use test;
+
+
+create  index rtree_index_point_0  on MyData (point) type rtree;
+
+create  index rtree_index_point  on MyMiniData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..7a43c93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.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.
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'id':m.id,'point':m.point}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..0b98557
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp
new file mode 100644
index 0000000..2cad192
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : using-constant-merge-policy.aql
+ * Description     : This test is intended to test the compact statement which merge the disk components of a dataset and
+ * all of its indexes using the constant merge policy.
+ * Expected Result : Success
+ * Date            : Sep 19 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy "constant"(("num-components"="2"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.3.ddl.sqlpp
new file mode 100644
index 0000000..873c727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.4.update.sqlpp
new file mode 100644
index 0000000..3e22ee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.4.update.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;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.5.query.sqlpp
new file mode 100644
index 0000000..5295e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp
new file mode 100644
index 0000000..58c0448
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : using-correlated-prefix-merge-policy.aql
+ * Description     : This test is intended to test the compact statement which merge the disk components of a dataset and
+ * all of its indexes using the correlated-prefix merge policy.
+ * Expected Result : Success
+ * Date            : Sep 19 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy "correlated-prefix"(("max-mergable-component-size"="1048576"),("max-tolerance-component-count"="3"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.3.ddl.sqlpp
new file mode 100644
index 0000000..873c727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.4.update.sqlpp
new file mode 100644
index 0000000..3e22ee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.4.update.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;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.5.query.sqlpp
new file mode 100644
index 0000000..5295e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp
new file mode 100644
index 0000000..b0e8228
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : cusing-no-merge-policy.aql
+ * Description     : This test is intended to test the compact statement which merge the disk components of a dataset and
+ * all of its indexes using the no merge policy.
+ * Expected Result : Success
+ * Date            : Sep 19 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy "no-merge";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.3.ddl.sqlpp
new file mode 100644
index 0000000..873c727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.4.update.sqlpp
new file mode 100644
index 0000000..3e22ee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.4.update.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;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.5.query.sqlpp
new file mode 100644
index 0000000..5295e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp
new file mode 100644
index 0000000..a41e9e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : cusing-prefix-merge-policy.aql
+ * Description     : This test is intended to test the compact statement which merge the disk components of a dataset and
+ * all of its indexes using the prefix merge policy.
+ * Expected Result : Success
+ * Date            : Sep 19 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy "prefix"(("max-mergable-component-size"="1048576"),("max-tolerance-component-count"="3"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.3.ddl.sqlpp
new file mode 100644
index 0000000..873c727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.4.update.sqlpp
new file mode 100644
index 0000000..3e22ee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.4.update.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;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.5.query.sqlpp
new file mode 100644
index 0000000..5295e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.1.ddl.sqlpp
new file mode 100644
index 0000000..f95d8d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpType as
+{
+  id : int64,
+  name : string,
+  address : {
+      number : int64,
+      street : string,
+      city : string
+  }
+,
+  age : int64?,
+  interests : {{string}}?,
+  children : [string]?
+}
+
+create external  table Emp(EmpType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/employee.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.3.query.sqlpp
new file mode 100644
index 0000000..7823d1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_01/q_01.3.query.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 element e
+from  Emp as e
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.1.ddl.sqlpp
new file mode 100644
index 0000000..f95d8d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpType as
+{
+  id : int64,
+  name : string,
+  address : {
+      number : int64,
+      street : string,
+      city : string
+  }
+,
+  age : int64?,
+  interests : {{string}}?,
+  children : [string]?
+}
+
+create external  table Emp(EmpType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/employee.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.3.query.sqlpp
new file mode 100644
index 0000000..7c8f2ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/employee/q_02/q_02.3.query.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.
+ */
+
+use test;
+
+
+select element m
+from  Emp as e
+with  m as [{'EmpName':e.name,'parent_interest_1':e.interests[?],'child1Name':e.children[?],'child2Name':e.children[1]}]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
new file mode 100644
index 0000000..c11881f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (tweetid) type btree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
new file mode 100644
index 0000000..ecf5895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
new file mode 100644
index 0000000..41856db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (tweetid) type btree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
new file mode 100644
index 0000000..90607b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
new file mode 100644
index 0000000..6b44e0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.query.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.
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.1.ddl.sqlpp
new file mode 100644
index 0000000..ee39039
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Create an external dataset that contains records stored with rc hdfs file format.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmployeeType as
+ closed {
+  id : int64,
+  name : string,
+  age : int64
+}
+
+create external  table EmployeeDataset(EmployeeType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/external-indexing-test.rc"),("input-format"="rc-input-format"),("format"="binary"),("parser"="hive-parser"),("hive-serde"="org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe"));
+
+create  index EmployeeAgeIdx  on EmployeeDataset (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.2.update.sqlpp
new file mode 100644
index 0000000..5531e02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with rc hdfs file format.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.3.query.sqlpp
new file mode 100644
index 0000000..0b3be95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rc-format/rc-format.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with rc hdfs file format.
+
+use test;
+
+
+select element emp
+from  EmployeeDataset as emp
+where (emp.age = 22)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..eb08ae6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialData.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..8426681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.1.ddl.sqlpp
new file mode 100644
index 0000000..103b3c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Create an external dataset that contains records stored with sequence hdfs file format.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmployeeType as
+ closed {
+  id : int64,
+  name : string,
+  age : int64
+}
+
+create external  table EmployeeDataset(EmployeeType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/external-indexing-test.seq"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create  index EmployeeAgeIdx  on EmployeeDataset (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.2.update.sqlpp
new file mode 100644
index 0000000..ab6ae4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with sequence hdfs file format.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.3.query.sqlpp
new file mode 100644
index 0000000..487ceb2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with sequence hdfs file format.
+
+use test;
+
+
+select element emp
+from  EmployeeDataset as emp
+where (emp.age = 22)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.1.ddl.sqlpp
new file mode 100644
index 0000000..453b14f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Create an external dataset that contains records stored with text hdfs file format.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmployeeType as
+ closed {
+  id : int64,
+  name : string,
+  age : int64
+}
+
+create external  table EmployeeDataset(EmployeeType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/external-indexing-test.txt"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="|"));
+
+create  index EmployeeAgeIdx  on EmployeeDataset (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.2.update.sqlpp
new file mode 100644
index 0000000..5964b88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.3.query.sqlpp
new file mode 100644
index 0000000..68f0c4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
+use test;
+
+
+select element emp
+from  EmployeeDataset as emp
+where (emp.age = 22)
+order by emp.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.ddl.sqlpp
new file mode 100644
index 0000000..30a07ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.2.update.sqlpp
new file mode 100644
index 0000000..2c89045
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.2.update.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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.3.query.sqlpp
new file mode 100644
index 0000000..38d2c9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/failure/q01_pricing_summary_report_failure/q01_pricing_summary_report_failure.3.query.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 tpch;
+
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':tpch.sum((
+        select element i.l_quantity
+        from  l as i
+    )),'sum_base_price':tpch.sum((
+        select element i.l_extendedprice
+        from  l as i
+    )),'sum_disc_price':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount))
+        from  l as i
+    )),'sum_charge':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+        from  l as i
+    )),'ave_qty':tpch.avg((
+        select element i.l_quantity
+        from  l as i
+    )),'ave_price':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'ave_disc':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'count_order':tpch.count(l)}
+from  LineItem as l
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.1.ddl.sqlpp
new file mode 100644
index 0000000..e6538da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Create a feed dataset and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  primary feed TweetFeed using file_feed (("output-type-name"="TweetType"),("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.2.update.sqlpp
new file mode 100644
index 0000000..fb120d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.2.update.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.
+ */
+/*
+ * Description  : Create a feed dataset and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.3.query.sqlpp
new file mode 100644
index 0000000..180044f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_01/feeds_01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+
+select element x
+from  "Metadata.Feed" as x
+where ((x.DataverseName = 'feeds') and (x.FeedName = 'TweetFeed'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.1.ddl.sqlpp
new file mode 100644
index 0000000..16e40b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  primary feed TweetFeed using file_feed (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.2.update.sqlpp
new file mode 100644
index 0000000..af5bb9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed TweetFeed to  table Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.3.query.sqlpp
new file mode 100644
index 0000000..bc54e72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_02/feeds_02.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.1.ddl.sqlpp
new file mode 100644
index 0000000..63c9909
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset with an associated function and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.2.update.sqlpp
new file mode 100644
index 0000000..63c9909
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.2.update.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.
+ */
+/*
+ * Description  : Create a feed dataset with an associated function and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.3.query.sqlpp
new file mode 100644
index 0000000..81f253e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_03/feeds_03.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset with an associated function and verify contents in Metadata
+ * Expected Res : Success
+ * Date         : 24th Dec 2012
+ */
+
+select element x
+from  "Metadata.Feed" as x
+where ((x.DataverseName = 'feeds') and (x.FeedName = 'TweetFeed'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.1.ddl.sqlpp
new file mode 100644
index 0000000..1c97c03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  primary feed TweetFeed using file_feed (("fs"="hdfs"),("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/obamatweets.adm"),("format"="adm"),("input-format"="text-input-format"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.2.update.sqlpp
new file mode 100644
index 0000000..af5bb9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed TweetFeed to  table Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.3.query.sqlpp
new file mode 100644
index 0000000..bc54e72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_04/feeds_04.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.1.ddl.sqlpp
new file mode 100644
index 0000000..09cece7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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  : Create a feed dataset that uses the synthetic feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type feeds.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table SyntheticTweets(TweetMessageType) primary key tweetid;
+
+create  primary feed SyntheticTweetFeed using twitter_firehose (("duration"="5"),("tps"="50"),("type-name"="TweetMessageType"),("tput-duration"="5"),("dataverse-dataset"="feeds:SyntheticTweets"),("mode"="controlled"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.2.update.sqlpp
new file mode 100644
index 0000000..a5044ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the synthetic feed simulator adapter.
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed SyntheticTweetFeed to  table SyntheticTweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.3.query.sqlpp
new file mode 100644
index 0000000..a7303aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_05/feeds_05.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the synthetic feed simulator adapter.
+
+use feeds;
+
+
+if ((feeds.count((
+      select element x
+      from  SyntheticTweets as x
+  )) > 0))
+then 1
+else 0;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.1.ddl.sqlpp
new file mode 100644
index 0000000..40df61f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset and a feed using the generic socket feed adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type feeds.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table MyTweets(TweetMessageType) primary key tweetid;
+
+create  table DummyTweets(TweetMessageType) primary key tweetid;
+
+create  primary feed socket_feed using socket_adapter (("sockets"="127.0.0.1:9009"),("addressType"="IP"),("type-name"="TweetMessageType"),("format"="adm"));
+create  primary feed client_test_feed using socket_client (("sockets"="127.0.0.1:9009"),("type-name"="TweetMessageType"),("addressType"="IP"),("format"="adm"),("file_splits"="data/twitter/tw_messages_100.adm"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.2.update.sqlpp
new file mode 100644
index 0000000..bf6461f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset and a feed using the generic socket feed adapter.
+
+use feeds;
+
+
+set "wait-for-completion-feed" "false";
+
+connect  feed socket_feed to  table MyTweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.3.sleep.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.3.sleep.sqlpp
new file mode 100644
index 0000000..c516444
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.3.sleep.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.
+ */
+
+select element 2000;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.4.update.sqlpp
new file mode 100644
index 0000000..410dede
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.4.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset and a feed using the generic socket feed adapter.
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed client_test_feed to  table DummyTweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.5.query.sqlpp
new file mode 100644
index 0000000..839b7e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_06/feeds_06.5.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset and a feed using the generic socket feed adapter.
+
+use feeds;
+
+
+select element x
+from  MyTweets as x
+order by x.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.1.ddl.sqlpp
new file mode 100644
index 0000000..c20a4e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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  : Create a feed using the synthetic feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type feeds.TweetMessageType as
+ closed {
+  id : int64,
+  user : TwitterUserType,
+  latitude : double,
+  longitude : double,
+  "send-time" : datetime,
+  message_text : string,
+  created_at : string,
+  country : string
+}
+
+create  table SyntheticTweets(TweetMessageType) primary key id;
+
+create  index locationIdx  on SyntheticTweets ("sender-location") type rtree;
+
+create  primary feed SyntheticTweetFeed using twitter_firehose (("duration"="5"),("tps"="50"),("type-name"="TweetMessageType"),("tput-duration"="5"),("dataverse-dataset"="feeds:SyntheticTweets"),("mode"="controlled"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.2.update.sqlpp
new file mode 100644
index 0000000..150f53d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed using the synthetic feed simulator adapter.                   
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed SyntheticTweetFeed to  table SyntheticTweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.3.query.sqlpp
new file mode 100644
index 0000000..18bed03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_07/feeds_07.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed using the synthetic feed simulator adapter.                   
+
+use feeds;
+
+
+if ((feeds.count((
+      select element x
+      from  SyntheticTweets as x
+  )) > 0))
+then 1
+else 0;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.1.ddl.sqlpp
new file mode 100644
index 0000000..76533da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed using the synthetic feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TwitterUserType as
+ closed {
+  screen_name : string,
+  language : string,
+  friends_count : int32,
+  status_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type feeds.TweetMessageType as
+ closed {
+  id : int64,
+  user : TwitterUserType,
+  latitude : double,
+  longitude : double,
+  message_text : string,
+  created_at : string,
+  country : string
+}
+
+create  table SyntheticTweets(TweetMessageType) primary key id;
+
+create  index ngram_index  on SyntheticTweets (message_text) type ngram (3);
+
+create  primary feed SyntheticTweetFeed using twitter_firehose (("duration"="5"),("tps"="50"),("type-name"="TweetMessageType"),("tput-duration"="5"),("dataverse-dataset"="feeds:SyntheticTweets"),("mode"="controlled"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.2.update.sqlpp
new file mode 100644
index 0000000..150f53d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed using the synthetic feed simulator adapter.                   
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed SyntheticTweetFeed to  table SyntheticTweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.3.query.sqlpp
new file mode 100644
index 0000000..18bed03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_08/feeds_08.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed using the synthetic feed simulator adapter.                   
+
+use feeds;
+
+
+if ((feeds.count((
+      select element x
+      from  SyntheticTweets as x
+  )) > 0))
+then 1
+else 0;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.1.ddl.sqlpp
new file mode 100644
index 0000000..cb6f2a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed using the synthetic feed simulator adapter. 
+
+drop  database feeds_09 if exists;
+create  database feeds_09;
+
+use feeds_09;
+
+
+create type feeds_09.TwitterUserType as
+ closed {
+  screen_name : string,
+  language : string,
+  friends_count : int32,
+  status_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type feeds_09.TweetMessageType as
+ closed {
+  id : int64,
+  user : TwitterUserType,
+  latitude : double,
+  longitude : double,
+  message_text : string,
+  created_at : string,
+  country : string
+}
+
+create  table SyntheticTweets(TweetMessageType) primary key id;
+
+create  index message_text  on SyntheticTweets (message_text) type btree;
+
+create  primary feed SyntheticTweetFeed using twitter_firehose (("duration"="5"),("tps"="50"),("tput-duration"="5"),("type-name"="TweetMessageType"),("dataverse-dataset"="feeds:SyntheticTweets"),("mode"="controlled"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.2.update.sqlpp
new file mode 100644
index 0000000..a556b0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed using the synthetic feed simulator adapter.                   
+
+use feeds_09;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed SyntheticTweetFeed to  table SyntheticTweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.3.query.sqlpp
new file mode 100644
index 0000000..dd270bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_09/feeds_09.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed using the synthetic feed simulator adapter.                   
+
+use feeds_09;
+
+
+if ((feeds_09.count((
+      select element x
+      from  SyntheticTweets as x
+  )) > 0))
+then 1
+else 0;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.1.ddl.sqlpp
new file mode 100644
index 0000000..c1ff9bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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  : Create a dataset with a secondary btree index.
+
+drop  database feeds_10 if exists;
+create  database feeds_10;
+
+use feeds_10;
+
+
+create type feeds_10.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  index usernameIdx  on Tweets (username) type btree;
+
+create  primary feed TweetFeed using file_feed (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.2.update.sqlpp
new file mode 100644
index 0000000..333a111
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a dataset with a secondary btree index.
+
+use feeds_10;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed TweetFeed to  table Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.3.query.sqlpp
new file mode 100644
index 0000000..350a632
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_10/feeds_10.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a dataset with a secondary btree index.
+
+use feeds_10;
+
+
+select element feeds_10.count((
+    select element x
+    from  Tweets as x
+    order by x.id
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.1.ddl.sqlpp
new file mode 100644
index 0000000..16e40b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  primary feed TweetFeed using file_feed (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.2.update.sqlpp
new file mode 100644
index 0000000..6e6520a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed feeds.TweetFeed to  table feeds.Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.3.query.sqlpp
new file mode 100644
index 0000000..bc54e72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_11/feeds_11.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.1.ddl.sqlpp
new file mode 100644
index 0000000..ff550e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed from the contents of  a file using a file_feed adaptor. 
+
+drop  database feeds_12 if exists;
+create  database feeds_12;
+
+use feeds_12;
+
+
+create type feeds_12.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  primary feed TweetFeed using file_feed (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets_duplicate.adm"),("format"="adm"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.2.update.sqlpp
new file mode 100644
index 0000000..1210401
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds_12;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed TweetFeed to  table Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.3.query.sqlpp
new file mode 100644
index 0000000..4b45439
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/feeds_12/feeds_12.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds_12;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.1.ddl.sqlpp
new file mode 100644
index 0000000..16e40b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  primary feed TweetFeed using file_feed (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.2.update.sqlpp
new file mode 100644
index 0000000..6e6520a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed feeds.TweetFeed to  table feeds.Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.3.query.sqlpp
new file mode 100644
index 0000000..bc54e72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_230_feeds/issue_230_feeds.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.1.ddl.sqlpp
new file mode 100644
index 0000000..5724057
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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  : Create a dataset with a secondary btree index.
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id;
+
+create  index usernameIdx  on Tweets (username) type btree;
+
+create  primary feed TweetFeed using file_feed (("fs"="hdfs"),("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/obamatweets.adm"),("format"="adm"),("input-format"="text-input-format"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.2.update.sqlpp
new file mode 100644
index 0000000..a7207f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a dataset with a secondary btree index.
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed TweetFeed to  table Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.3.query.sqlpp
new file mode 100644
index 0000000..8c545a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/feeds/issue_711_feeds/issue_711_feeds.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a dataset with a secondary btree index.
+
+use feeds;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.1.ddl.sqlpp
new file mode 100644
index 0000000..db43a98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test filters with equality predicate
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.3.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.3.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.5.query.sqlpp
new file mode 100644
index 0000000..0e6e3a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/equality-predicate/equality-predicate.5.query.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.
+ */
+
+use test;
+
+
+select element m
+from  FacebookMessages as m
+where (m."send-time" = test.datetime('2014-01-20T10:10:00'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.1.ddl.sqlpp
new file mode 100644
index 0000000..13a5ac1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : Test filters with insert pipeline in the existence of a secondary b-tree
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table FacebookMessages2(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.3.ddl.sqlpp
new file mode 100644
index 0000000..262db8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.3.ddl.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;
+
+
+create  index fbAuthorIdx  on FacebookMessages2 ("author-id") type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.4.update.sqlpp
new file mode 100644
index 0000000..cd4fe32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.4.update.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.
+ */
+
+use test;
+
+
+insert into FacebookMessages2
+select element m
+from  FacebookMessages as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.5.query.sqlpp
new file mode 100644
index 0000000..17ba5f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.5.query.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.
+ */
+
+use test;
+
+
+select element m
+from  FacebookMessages2 as m
+where ((m."author-id" = 1) and (m."send-time" > test.datetime('2012-08-20T10:10:00')) and (m."send-time" < test.datetime('2012-11-20T10:10:00')))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.1.ddl.sqlpp
new file mode 100644
index 0000000..258ed93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : Test filters with insert pipeline in the existence of a secondary ngram index
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table FacebookMessages2(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.3.ddl.sqlpp
new file mode 100644
index 0000000..14b65f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.3.ddl.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;
+
+
+create  index fbMessageIdx  on FacebookMessages2 (message) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.4.update.sqlpp
new file mode 100644
index 0000000..cd4fe32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.4.update.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.
+ */
+
+use test;
+
+
+insert into FacebookMessages2
+select element m
+from  FacebookMessages as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.5.query.sqlpp
new file mode 100644
index 0000000..a7f75d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element m
+from  FacebookMessages as m
+where (test.contains(m.message,'love') and (m."send-time" < test.datetime('2012-12-20T10:10:00')))
+order by m."send-time"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.1.ddl.sqlpp
new file mode 100644
index 0000000..2df0d71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : Test filters with insert pipeline in the existence of a secondary word index
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table FacebookMessages2(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.3.ddl.sqlpp
new file mode 100644
index 0000000..9fdd0df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.3.ddl.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;
+
+
+create  index fbMessageIdx  on FacebookMessages2 (message) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.4.update.sqlpp
new file mode 100644
index 0000000..cd4fe32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.4.update.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.
+ */
+
+use test;
+
+
+insert into FacebookMessages2
+select element m
+from  FacebookMessages as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.5.query.sqlpp
new file mode 100644
index 0000000..096d944
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element m
+from  FacebookMessages as m
+where ((test."similarity-jaccard"(test."word-tokens"(m.message),test."word-tokens"('love sprint at&t verizon')) >= 0.200000f) and (m."send-time" < test.datetime('2012-12-20T10:10:00')))
+order by m."send-time"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.1.ddl.sqlpp
new file mode 100644
index 0000000..f4e90a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : Test filters with insert pipeline in the existence of a secondary r-tree
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table FacebookMessages2(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.3.ddl.sqlpp
new file mode 100644
index 0000000..fef4b09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.3.ddl.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;
+
+
+create  index fbSenderLocIndex  on FacebookMessages2 ("sender-location") type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.4.update.sqlpp
new file mode 100644
index 0000000..cd4fe32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.4.update.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.
+ */
+
+use test;
+
+
+insert into FacebookMessages2
+select element m
+from  FacebookMessages as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.5.query.sqlpp
new file mode 100644
index 0000000..83e7532
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element m
+from  FacebookMessages as m
+where (test."spatial-intersect"(m."sender-location",test."create-polygon"([40.0,79.87,30.0,75.0,50.0,80.0,10.0,10.0])) and (m."send-time" < test.datetime('2012-11-20T10:10:00.000Z')))
+order by m."send-time"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.1.ddl.sqlpp
new file mode 100644
index 0000000..ddc2aba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : Test filters with insert pipeline
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table FacebookMessages2(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.3.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.3.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.4.update.sqlpp
new file mode 100644
index 0000000..cd4fe32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.4.update.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.
+ */
+
+use test;
+
+
+insert into FacebookMessages2
+select element m
+from  FacebookMessages as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.5.query.sqlpp
new file mode 100644
index 0000000..0d94267
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert/insert.5.query.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.
+ */
+
+use test;
+
+
+select element m
+from  FacebookMessages2 as m
+where (m."send-time" > test.datetime('2012-08-20T10:10:00'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.1.ddl.sqlpp
new file mode 100644
index 0000000..cc8df33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test filters with loading and in the existence of a secondary b-tree
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.3.ddl.sqlpp
new file mode 100644
index 0000000..07af51b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.3.ddl.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;
+
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.5.query.sqlpp
new file mode 100644
index 0000000..711a4f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.5.query.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.
+ */
+
+use test;
+
+
+select element m
+from  FacebookMessages as m
+where ((m."author-id" = 1) and (m."send-time" > test.datetime('2012-08-20T10:10:00')) and (m."send-time" < test.datetime('2012-11-20T10:10:00')))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.1.ddl.sqlpp
new file mode 100644
index 0000000..ae8717e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test filters with loading and in the existence of a secondary ngram index
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.3.ddl.sqlpp
new file mode 100644
index 0000000..1c70867
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.3.ddl.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;
+
+
+create  index fbMessageIdx  on FacebookMessages (message) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.5.query.sqlpp
new file mode 100644
index 0000000..a7f75d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element m
+from  FacebookMessages as m
+where (test.contains(m.message,'love') and (m."send-time" < test.datetime('2012-12-20T10:10:00')))
+order by m."send-time"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.1.ddl.sqlpp
new file mode 100644
index 0000000..e5fc0c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test filters with loading and in the existence of a secondary word index
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.3.ddl.sqlpp
new file mode 100644
index 0000000..fe0335a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.3.ddl.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;
+
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.5.query.sqlpp
new file mode 100644
index 0000000..096d944
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element m
+from  FacebookMessages as m
+where ((test."similarity-jaccard"(test."word-tokens"(m.message),test."word-tokens"('love sprint at&t verizon')) >= 0.200000f) and (m."send-time" < test.datetime('2012-12-20T10:10:00')))
+order by m."send-time"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.1.ddl.sqlpp
new file mode 100644
index 0000000..b333544
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test filters with loading and in the existence of a secondary r-tree
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.3.ddl.sqlpp
new file mode 100644
index 0000000..3b7cdd8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.3.ddl.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;
+
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.5.query.sqlpp
new file mode 100644
index 0000000..83e7532
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element m
+from  FacebookMessages as m
+where (test."spatial-intersect"(m."sender-location",test."create-polygon"([40.0,79.87,30.0,75.0,50.0,80.0,10.0,10.0])) and (m."send-time" < test.datetime('2012-11-20T10:10:00.000Z')))
+order by m."send-time"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.1.ddl.sqlpp
new file mode 100644
index 0000000..4b9f4ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : Test filters with loading
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id" with filter on "send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.2.update.sqlpp
new file mode 100644
index 0000000..7b91e1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.2.update.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;
+
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.3.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.3.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.5.query.sqlpp
new file mode 100644
index 0000000..eda988a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/load/load.5.query.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.
+ */
+
+use test;
+
+
+select element m
+from  FacebookMessages as m
+where (m."send-time" > test.datetime('2012-08-20T10:10:00'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.1.ddl.sqlpp
new file mode 100644
index 0000000..d1eeced
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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  : Test filters with equality predicate
+ * Expected Res : Success
+ * Date         : 25th Jun 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.FacebookMessageTypeTmp as
+ closed {
+  "message-id" : int32,
+  "author-id" : int32,
+  "in-response-to" : int32?,
+  "sender-location" : point?,
+  message : string,
+  "send-time" : datetime
+}
+
+create type test.FacebookMessageType as
+ closed {
+  nested : FacebookMessageTypeTmp
+}
+
+create  table FacebookMessagesTmp(FacebookMessageTypeTmp) primary key "message-id";
+
+create  table FacebookMessages(FacebookMessageType) primary key nested."message-id" with filter on nested."send-time";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.2.update.sqlpp
new file mode 100644
index 0000000..bf2ffd4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.2.update.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.
+ */
+
+use test;
+
+
+load  table FacebookMessagesTmp using "localfs" (("path"="nc1://data/fbm-with-send-time.adm"),("format"="adm"));
+
+insert into FacebookMessages
+select element {'nested':c}
+from  FacebookMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.3.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.3.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.4.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.4.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.5.query.sqlpp
new file mode 100644
index 0000000..87698a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/nested-filter-equality-predicate/equality-predicate.5.query.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.
+ */
+
+use test;
+
+
+select element m.nested
+from  FacebookMessages as m
+where (m.nested."send-time" = test.datetime('2014-01-20T10:10:00'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.1.ddl.sqlpp
new file mode 100644
index 0000000..eb31c37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.2.update.sqlpp
new file mode 100644
index 0000000..a8147bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.3.query.sqlpp
new file mode 100644
index 0000000..3a2e884
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+use test;
+
+
+select element {'partkey':gen0.partkey,'pid':p,'shipdate':j.l_shipdate}
+from
+    ( select element {'partkey':partkey,'i':i}
+      from  LineItem as i
+      group by i.l_partkey as partkey
+    ) as gen0,
+    gen0.i as j at p
+where (p < 4)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.4.asyncdefer.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.4.asyncdefer.sqlpp
new file mode 100644
index 0000000..3a2e884
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.4.asyncdefer.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+use test;
+
+
+select element {'partkey':gen0.partkey,'pid':p,'shipdate':j.l_shipdate}
+from
+    ( select element {'partkey':partkey,'i':i}
+      from  LineItem as i
+      group by i.l_partkey as partkey
+    ) as gen0,
+    gen0.i as j at p
+where (p < 4)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.5.async.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.5.async.sqlpp
new file mode 100644
index 0000000..3a2e884
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at00/at00.5.async.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+use test;
+
+
+select element {'partkey':gen0.partkey,'pid':p,'shipdate':j.l_shipdate}
+from
+    ( select element {'partkey':partkey,'i':i}
+      from  LineItem as i
+      group by i.l_partkey as partkey
+    ) as gen0,
+    gen0.i as j at p
+where (p < 4)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.1.ddl.sqlpp
new file mode 100644
index 0000000..1909479
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.2.update.sqlpp
new file mode 100644
index 0000000..dc2622d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.3.query.sqlpp
new file mode 100644
index 0000000..3222f13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at01/at01.3.query.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.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+select element {'num':p,'name':i.name,'user-since':i."user-since"}
+from  (
+    select element fb
+    from  FacebookUsers as fb
+    order by fb.name
+) as i at p
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.1.ddl.sqlpp
new file mode 100644
index 0000000..99e750d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.1.ddl.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression, using partitioned group-by
+ * Expected Result  :  Success
+ * Date             :  07/27/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type test.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.2.update.sqlpp
new file mode 100644
index 0000000..0203da8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression, using partitioned group-by
+ * Expected Result  :  Success
+ * Date             :  07/27/2013
+ */
+
+use test;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.3.query.sqlpp
new file mode 100644
index 0000000..c124dcd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at02/at02.3.query.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression, using partitioned group-by
+ * Expected Result  :  Success
+ * Date             :  07/27/2013
+ */
+
+use test;
+
+
+select element {'group':g,'item':(
+        select element {'num':p,'mid':a."message-id"}
+        from  (
+            select element ii
+            from  m as ii
+            order by ii."message-id"
+        ) as a at p
+    )}
+from  FacebookUsers as u,
+      FacebookMessages as m
+where (u.id = m."author-id")
+group by u.id as g
+order by g
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.1.ddl.sqlpp
new file mode 100644
index 0000000..f1222df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression nested in group-by
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserType as
+ closed {
+  id : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.2.update.sqlpp
new file mode 100644
index 0000000..0375f42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression nested in group-by
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.3.query.sqlpp
new file mode 100644
index 0000000..50ea0a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at03/at03.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression nested in group-by
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+select element {'user-since':fus,'users':(
+        select element {'num':ip,'name':f.name}
+        from  (
+            select element i1
+            from  i as i1
+            order by i1.name
+        ) as f at ip
+    )}
+from  (
+    select element fb
+    from  FacebookUsers as fb
+) as i
+group by test."get-year"(i."user-since") as fus
+order by fus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.1.ddl.sqlpp
new file mode 100644
index 0000000..27d2c49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression using tpch
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.2.update.sqlpp
new file mode 100644
index 0000000..14509f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression using tpch dataset
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders-part1.tbl,nc2://data/tpch0.001/orders-part2.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.3.query.sqlpp
new file mode 100644
index 0000000..cbe542a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at04/at04.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression using tpch
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+select element {'o_custkey':ckey,'users':(
+        select element {'num':ip,'orderkey':f.o_orderkey}
+        from  (
+            select element i1
+            from  i as i1
+            order by i1.o_orderkey
+        ) as f at ip
+    )}
+from  (
+    select element o
+    from  Orders as o
+) as i
+group by i.o_custkey as ckey
+order by ckey
+limit 3
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.1.ddl.sqlpp
new file mode 100644
index 0000000..27d2c49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression using tpch
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.2.update.sqlpp
new file mode 100644
index 0000000..14509f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression using tpch dataset
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders-part1.tbl,nc2://data/tpch0.001/orders-part2.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.3.query.sqlpp
new file mode 100644
index 0000000..7905776
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at05/at05.3.query.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression using tpch
+ * Expected Result  :  Success
+ * Date             :  07/18/2013
+ */
+
+use test;
+
+
+select element si
+from
+    ( select element {'xx':xx,'x':x,'uid':uid}
+      from  Orders as x
+      where (x.o_custkey < 4)
+      group by x.o_custkey as uid
+      with  xx as (
+            select element {'uid':uid,'seq':i,'item':y.o_orderkey}
+            from  (
+                select element xxx
+                from  x as xxx
+                order by xxx.o_orderkey
+            ) as y at i
+        )
+      order by uid
+    ) as gen0,
+    gen0.xx as si
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.1.ddl.sqlpp
new file mode 100644
index 0000000..eb31c37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.2.update.sqlpp
new file mode 100644
index 0000000..a8147bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.3.query.sqlpp
new file mode 100644
index 0000000..881b15f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/at06/at06.3.query.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  09/17/2013
+ */
+
+use test;
+
+
+select element {'partkey':gen0.partkey,'pid':p,'shipdate':j.l_shipdate,'orderkey':j.l_orderkey}
+from
+    ( select element {'partkey':partkey,'i':i}
+      from  LineItem as i
+      group by i.l_partkey as partkey
+    ) as gen0,
+    (
+  select element ii
+  from  gen0.i as ii
+  order by ii.l_shipdate
+) as j at p
+where (p < 4)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.1.ddl.sqlpp
new file mode 100644
index 0000000..a0253ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.2.update.sqlpp
new file mode 100644
index 0000000..a0253ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.3.query.sqlpp
new file mode 100644
index 0000000..f2c37d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for01/for01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  23rd July 2012
+ */
+
+select element a
+from  [1,2,3,4,5,6,7,8,9] as a
+where not(false)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.3.query.sqlpp
new file mode 100644
index 0000000..449bc99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for02/for02.3.query.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element (
+    select element b
+    from  a as b
+    where ((b > 5) and (b < 70))
+)
+from  [[1,2,3,4,5,6,7,8,9],[20,30,40,50,60,70,80]] as a
+where true
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.3.query.sqlpp
new file mode 100644
index 0000000..9021f86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for03/for03.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [[1,2,3,4,5,6,7,8,9,0],['r','t','w','a'],[11,34,56,78,98,1,12,34,56,76,83],[null,null,null],[' ','','    '],['at'],[-1],[0]] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.3.query.sqlpp
new file mode 100644
index 0000000..8f0d67e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for04/for04.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [[1,2,3,4,5,6,7,8,9,0],[11,34,56,78,98,1,12,34,56,76,83],[null,null,null,'and','bat','gone','do'],[' ','','    '],['at'],[-1],[0]] as a
+where (len(a) > 1)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.3.query.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for05/for05.3.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.3.query.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for06/for06.3.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.3.query.sqlpp
new file mode 100644
index 0000000..73b8373
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for07/for07.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [{'name':'Bob','age':10,'sex':'Male'},{'name':'John','age':45,'sex':'Female'},{'name':'Raj','age':35,'sex':'Male'}] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.3.query.sqlpp
new file mode 100644
index 0000000..53ac49a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for08/for08.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [{'name':'Bob','age':10,'sex':'Male'},{'name':'John','age':45,'sex':'Female'},{'name':'Raj','age':35,'sex':'Male'}] as a
+where (a.name = 'John')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.3.query.sqlpp
new file mode 100644
index 0000000..9cbd2b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for09/for09.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [{'name':'Bob','age':10,'sex':'Male'},{'name':'John','age':45,'sex':'Female'},{'name':'Raj','age':35,'sex':'Male'}] as a
+where (a.name = 'Tom')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.3.query.sqlpp
new file mode 100644
index 0000000..d8cb741
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for10/for10.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element {'a':a,'additional-data':{{'this is additional data','this is too','and this is additional too'}}}
+from  [{'name':'Bob','age':10,'sex':'Male'},{'name':'John','age':45,'sex':'Female'},{'name':'Raj','age':35,'sex':'Male'}] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.3.query.sqlpp
new file mode 100644
index 0000000..d7d36f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for11/for11.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element {{'this is additional data','this is too','and this is additional too'}}
+from  [true,true,false,true] as a
+where (a = true)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.3.query.sqlpp
new file mode 100644
index 0000000..5e2162a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for12/for12.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element {'a':{{'this is additional data','this is too','and this is additional too'}},'b':{{'this is additional data','this is too','and this is additional too'}}}
+from  [true,true,false,true] as a
+where (a = false)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.3.query.sqlpp
new file mode 100644
index 0000000..2ac5047
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for13/for13.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element {{'this is additional data','this is too','and this is additional too'}}
+from  [true] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.3.query.sqlpp
new file mode 100644
index 0000000..0b3f8e6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for14/for14.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [{'name':'Rocky','age':59,'sex':'M'},['job','ink','king','ontario','lavelle'],[1,4,5,6,7,8,9,2,3,4,5,6,7],{{'extra data','extra data','extra data'}}] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.3.query.sqlpp
new file mode 100644
index 0000000..9cdd9ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for15/for15.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [{'name':'Rocky','age':59,'sex':'M'},[1]] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.3.query.sqlpp
new file mode 100644
index 0000000..6ea430b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for16/for16.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [[[1,2],[3]],[[4,5],[6,7]],[[8,9],[10,11]],[[12,13],[14]],[[15],[16,17]],[[18],[19,20]]] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.1.ddl.sqlpp
new file mode 100644
index 0000000..d0f1259
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.1.ddl.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.
+ */
+/*
+ * Description     : Test union of two lists
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.2.update.sqlpp
new file mode 100644
index 0000000..d0f1259
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.2.update.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.
+ */
+/*
+ * Description     : Test union of two lists
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.3.query.sqlpp
new file mode 100644
index 0000000..b481ca8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for17/for17.3.query.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.
+ */
+/*
+ * Description     : Test union of two lists
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element (
+    select element a
+    from  [{'id':1234,'name':'John Doe','age':56,'salary':50000,'dept':'HR'}] as a
+)
+    union
+    (
+    select element b
+    from  [{'id':3424,'name':'Roger Sanders','age':46,'salary':60000,'dept':'Publishing'}] as b
+);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.1.ddl.sqlpp
new file mode 100644
index 0000000..d07b961
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.1.ddl.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.
+ */
+/*
+ * Description     : Test nested for and return
+ * Expected Result : Success
+ * Date            : 21st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.2.update.sqlpp
new file mode 100644
index 0000000..d07b961
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.2.update.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.
+ */
+/*
+ * Description     : Test nested for and return
+ * Expected Result : Success
+ * Date            : 21st Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.3.query.sqlpp
new file mode 100644
index 0000000..196fea5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for18/for18.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test nested for and return
+ * Expected Result : Success
+ * Date            : 21st Aug 2012
+ */
+
+select element (a + 1)
+from  (
+    select element (b + 1)
+    from  (
+        select element (c + 1)
+        from  (
+            select element (d + 1)
+            from  [1,2,3,4,5,6,7] as d
+        ) as c
+    ) as b
+) as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.1.ddl.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.2.update.sqlpp
new file mode 100644
index 0000000..06bd87e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.2.update.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.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.3.query.sqlpp
new file mode 100644
index 0000000..a7bf519
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/for19/for19.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element a
+from  [[1,2,3,4,5,6,7,8,9,0],[11,34,56,78,98,1,12,34,56,76,83]] as a
+where (len(a) > 1)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.1.ddl.sqlpp
new file mode 100644
index 0000000..bce7b22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.1.ddl.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.
+ */
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.2.update.sqlpp
new file mode 100644
index 0000000..bce7b22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.2.update.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.
+ */
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.3.query.sqlpp
new file mode 100644
index 0000000..8f778b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby01/grpby01.3.query.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.
+ */
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
+select element {'store-number':strNum,'total-qty':sum((
+        select element l.qty
+        from  sales as l
+    ))}
+from  [{'storeno':'S101','itemno':'P78395','qty':125},{'storeno':'S101','itemno':'P71395','qty':135},{'storeno':'S102','itemno':'P78395','qty':225},{'storeno':'S103','itemno':'P78345','qty':105},{'storeno':'S104','itemno':'P71395','qty':115},{'storeno':'S105','itemno':'P74395','qty':120}] as sales
+group by sales.storeno as strNum
+order by strNum desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.1.ddl.sqlpp
new file mode 100644
index 0000000..bce7b22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.1.ddl.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.
+ */
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.2.update.sqlpp
new file mode 100644
index 0000000..bce7b22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.2.update.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.
+ */
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.3.query.sqlpp
new file mode 100644
index 0000000..8f778b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/grpby02/grpby02.3.query.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.
+ */
+/*
+ * Description      :  Test group by clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  31st July 2012
+ */
+
+select element {'store-number':strNum,'total-qty':sum((
+        select element l.qty
+        from  sales as l
+    ))}
+from  [{'storeno':'S101','itemno':'P78395','qty':125},{'storeno':'S101','itemno':'P71395','qty':135},{'storeno':'S102','itemno':'P78395','qty':225},{'storeno':'S103','itemno':'P78345','qty':105},{'storeno':'S104','itemno':'P71395','qty':115},{'storeno':'S105','itemno':'P74395','qty':120}] as sales
+group by sales.storeno as strNum
+order by strNum desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.3.query.sqlpp
new file mode 100644
index 0000000..f054fc1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let01/let01.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+int64('92233720368547758');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.3.query.sqlpp
new file mode 100644
index 0000000..34341d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let02/let02.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+92233720368547758;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.3.query.sqlpp
new file mode 100644
index 0000000..2b1f9d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let03/let03.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+(int64('92233720368547758') + 1);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.3.query.sqlpp
new file mode 100644
index 0000000..dee2e53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let04/let04.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+double('1.7976931348623157E308');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.3.query.sqlpp
new file mode 100644
index 0000000..32eac82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let05/let05.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+{'a':(1 + (1 * (100 / 20)))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.3.query.sqlpp
new file mode 100644
index 0000000..e017b1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let06/let06.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+1;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.3.query.sqlpp
new file mode 100644
index 0000000..4dae497
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let07/let07.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+(1 + 1);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.3.query.sqlpp
new file mode 100644
index 0000000..fd7d650
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let08/let08.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+with  x as [1,2,3]
+select element y
+from  x as b
+with  y as (b + 1)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.3.query.sqlpp
new file mode 100644
index 0000000..a317a5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let09/let09.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+select element a
+from  range(1,100) as a
+where ((a % 5) = 0)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.3.query.sqlpp
new file mode 100644
index 0000000..67d1c90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let10/let10.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+with  x as [1,2,3,4,5,6,7,8,9,10,11,14,15,17,19,24,35,56,67,77,89,60,35,25,60]
+select element y
+from  x as y
+where ((y % 5) = 0)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.3.query.sqlpp
new file mode 100644
index 0000000..f88d240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let11/let11.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+['a',{'i':1},'b',{'j':2},'c',{'k':3}];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.3.query.sqlpp
new file mode 100644
index 0000000..4dae497
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let12/let12.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+(1 + 1);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.1.ddl.sqlpp
new file mode 100644
index 0000000..40c8314
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Failure - Negative test
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.2.update.sqlpp
new file mode 100644
index 0000000..40c8314
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Failure - Negative test
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.3.query.sqlpp
new file mode 100644
index 0000000..40c8314
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let13/let13.3.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Failure - Negative test
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.3.query.sqlpp
new file mode 100644
index 0000000..13bb4a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let14/let14.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+[[[[[[[[[[[[1,2,3,4,5,6,7,8,9,10],[3,4,5,6,7,8,9,0,0],int64('9222872036854775809')]]]]]]]]]]];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.3.query.sqlpp
new file mode 100644
index 0000000..0d99f57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let15/let15.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+[[[[[[[[[[[int64('9222872036854775809')]]]]]]]]]]];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.3.query.sqlpp
new file mode 100644
index 0000000..3b9d783
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let16/let16.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+[[[[[[[[[[[int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809'),int64('9222872036854775809')]]]]]]]]]]];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.3.query.sqlpp
new file mode 100644
index 0000000..5a051c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let17/let17.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+['and','here','we','are',['this is new','stuff']];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.3.query.sqlpp
new file mode 100644
index 0000000..1b87708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let18/let18.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+[{{'John Doe',45,'HR',60000,'Separation'}}];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.3.query.sqlpp
new file mode 100644
index 0000000..11a5546
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let19/let19.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+{{'John Doe',45,'HR',60000,'Separation'}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.1.ddl.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.1.ddl.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.2.update.sqlpp
new file mode 100644
index 0000000..e159713
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.2.update.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.3.query.sqlpp
new file mode 100644
index 0000000..caff622
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let20/let20.3.query.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.
+ */
+/*
+ * Description     :  Test let clause
+ * Expected Result :  Success
+ * Date            :  6th July 2012 
+ */
+
+[{{'John Doe',45,'HR',60000,'Separation'}},{'name':'Roger Sanders','age':50,'dept':'DB2-Books','designatin':'Author'},['DB2 for Z/OS','DB2 for LUW','DB2 9 Application Development','DB2 9 DBA','DB2 for Dummies']];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.1.ddl.sqlpp
new file mode 100644
index 0000000..2f97a80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.1.ddl.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.
+ */
+/*
+ * Description      :  Test let clause
+ * Expected Result  :  Success
+ * Date             :  23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.2.update.sqlpp
new file mode 100644
index 0000000..2f97a80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.2.update.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.
+ */
+/*
+ * Description      :  Test let clause
+ * Expected Result  :  Success
+ * Date             :  23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.3.query.sqlpp
new file mode 100644
index 0000000..dda757a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let21/let21.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test let clause
+ * Expected Result  :  Success
+ * Date             :  23rd July 2012
+ */
+
+with  a as [boolean('true'),boolean('false'),boolean('true'),boolean('false')],
+      b as [boolean('false'),boolean('true'),boolean('false'),boolean('true')]
+select element m
+from  a as m,
+      b as n
+where (m = not(n))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.1.ddl.sqlpp
new file mode 100644
index 0000000..e7ea9f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.1.ddl.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.
+ */
+/*
+ * Description     : Test length of null returned by len() function  
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.2.update.sqlpp
new file mode 100644
index 0000000..e7ea9f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.2.update.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.
+ */
+/*
+ * Description     : Test length of null returned by len() function  
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.3.query.sqlpp
new file mode 100644
index 0000000..e51f25b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let22/let22.3.query.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.
+ */
+/*
+ * Description     : Test length of null returned by len() function  
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
+len([null]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.1.ddl.sqlpp
new file mode 100644
index 0000000..c254e0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.1.ddl.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.
+ */
+/*
+ * Description     : Test length of ordered list
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.2.update.sqlpp
new file mode 100644
index 0000000..c254e0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.2.update.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.
+ */
+/*
+ * Description     : Test length of ordered list
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.3.query.sqlpp
new file mode 100644
index 0000000..bda1fbe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let23/let23.3.query.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.
+ */
+/*
+ * Description     : Test length of ordered list
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
+len([1,2,3,4,5,6,7,8,9,null]);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.1.ddl.sqlpp
new file mode 100644
index 0000000..ee4edfd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.1.ddl.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.
+ */
+/*
+ *  Description     : Test let clause
+ *  Expected Result : Success
+ *  Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.2.update.sqlpp
new file mode 100644
index 0000000..ee4edfd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.2.update.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.
+ */
+/*
+ *  Description     : Test let clause
+ *  Expected Result : Success
+ *  Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.3.query.sqlpp
new file mode 100644
index 0000000..5af9a86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let24/let24.3.query.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.
+ */
+/*
+ *  Description     : Test let clause
+ *  Expected Result : Success
+ *  Date            : 23rd July 2012
+ */
+
+{'m':{'name':'Holmes S','age':25,'sex':'M'},'n':{'name':'Bob','age':35,'sex':null},'o':{{'John',45,'M'}},'p':{{'Optional data goes here',null}},'q':{'id':1345,'test':{'name':'Federer','age':35},'foo':'foo'}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.1.ddl.sqlpp
new file mode 100644
index 0000000..685f9dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.1.ddl.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.
+ */
+/*
+ * Description     : Test let clause
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.2.update.sqlpp
new file mode 100644
index 0000000..685f9dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.2.update.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.
+ */
+/*
+ * Description     : Test let clause
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.3.query.sqlpp
new file mode 100644
index 0000000..d0e2404
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let25/let25.3.query.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.
+ */
+/*
+ * Description     : Test let clause
+ * Expected Result : Success
+ * Date            : 23rd July 2012
+ */
+
+{'a':(true or false),'b':((true or false) and not(false))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.1.ddl.sqlpp
new file mode 100644
index 0000000..bf0b8bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.1.ddl.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.
+ */
+/*
+ * Description     : Test let clause 
+ * Expected Result : Success 
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.2.update.sqlpp
new file mode 100644
index 0000000..bf0b8bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.2.update.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.
+ */
+/*
+ * Description     : Test let clause 
+ * Expected Result : Success 
+ * Date            : 23rd July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.3.query.sqlpp
new file mode 100644
index 0000000..5c3d742
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let26/let26.3.query.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.
+ */
+/*
+ * Description     : Test let clause 
+ * Expected Result : Success 
+ * Date            : 23rd July 2012
+ */
+
+{'a':(10 > 9),'b':((((100 * 100) / 10) - 1999) > 3900),'c':(true != false)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.1.ddl.sqlpp
new file mode 100644
index 0000000..f2e0716
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.1.ddl.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.
+ */
+/*
+ * Description     : Test let clause 
+ * Expected Result : Success 
+ * Date            : 23rd July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.2.update.sqlpp
new file mode 100644
index 0000000..f2e0716
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.2.update.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.
+ */
+/*
+ * Description     : Test let clause 
+ * Expected Result : Success 
+ * Date            : 23rd July 2012 
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.3.query.sqlpp
new file mode 100644
index 0000000..23f6331
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let27/let27.3.query.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.
+ */
+/*
+ * Description     : Test let clause 
+ * Expected Result : Success 
+ * Date            : 23rd July 2012 
+ */
+
+[(100 + 100),(100 - 100),(100 * 100),(100 / 100),(100 % 10)];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.1.ddl.sqlpp
new file mode 100644
index 0000000..ebc42ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.1.ddl.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.
+ */
+/*
+ * Description     : Test let clause and floating point literals
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.2.update.sqlpp
new file mode 100644
index 0000000..ebc42ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.2.update.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.
+ */
+/*
+ * Description     : Test let clause and floating point literals
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.3.query.sqlpp
new file mode 100644
index 0000000..f916649
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let28/let28.3.query.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.
+ */
+/*
+ * Description     : Test let clause and floating point literals
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+[137.893204f,156.000000f,0.987810f,436.218994f,0.892170f,16789.000000f];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.1.ddl.sqlpp
new file mode 100644
index 0000000..518b5d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.1.ddl.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.
+ */
+/*
+ * Description     : Test let clause and double literals
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.2.update.sqlpp
new file mode 100644
index 0000000..518b5d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.2.update.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.
+ */
+/*
+ * Description     : Test let clause and double literals
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.3.query.sqlpp
new file mode 100644
index 0000000..bb010a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let29/let29.3.query.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.
+ */
+/*
+ * Description     : Test let clause and double literals
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+[137.8932,0.98781,436.219,0.89217,-234.324];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.1.ddl.sqlpp
new file mode 100644
index 0000000..e3d5708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.1.ddl.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.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.2.update.sqlpp
new file mode 100644
index 0000000..e3d5708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.2.update.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.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.3.query.sqlpp
new file mode 100644
index 0000000..e3e17a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let30/let30.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+[{'id':1234,'name':'John Doe','age':56,'salary':50000,'dept':'HR'}]
+union
+[{'id':3424,'name':'Roger Sanders','age':46,'salary':60000,'dept':'Publishing'}];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.1.ddl.sqlpp
new file mode 100644
index 0000000..e3d5708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.1.ddl.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.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.2.update.sqlpp
new file mode 100644
index 0000000..e3d5708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.2.update.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.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.3.query.sqlpp
new file mode 100644
index 0000000..56bb17e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let31/let31.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+{'id':1234,'name':'John Doe','age':56,'salary':50000,'dept':'HR'}
+union
+{'id':3424,'name':'Roger Sanders','age':46,'salary':60000,'dept':'Publishing'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.1.ddl.sqlpp
new file mode 100644
index 0000000..e3d5708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.1.ddl.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.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.2.update.sqlpp
new file mode 100644
index 0000000..e3d5708
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.2.update.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.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.3.query.sqlpp
new file mode 100644
index 0000000..d9ad6d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let32/let32.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test union of two lists, bind each list to a variable
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element a
+from  [{'id':1234,'name':'John Doe','age':56,'salary':50000,'dept':'HR'}] as a
+
+union
+select element b
+from  [{'id':3424,'name':'Roger Sanders','age':46,'salary':60000,'dept':'Publishing'}] as b
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.1.ddl.sqlpp
new file mode 100644
index 0000000..17ac895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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     : Test hoisting a variable that does not get inlined
+ * Expected Result : Success
+ * Date            : 8th November 2013
+ */
+
+drop  database foo if exists;
+create  database foo if not exists ;
+
+use foo;
+
+
+create type foo.fbuser as
+{
+  id : int32,
+  name : string
+}
+
+create  table fb(fbuser) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.2.update.sqlpp
new file mode 100644
index 0000000..1536a9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test hoisting a variable that does not get inlined
+ * Expected Result : Success
+ * Date            : 8th November 2013
+ */
+
+use foo;
+
+
+insert into fb
+select element {'id':1,'name':'Tom'};
+insert into fb
+select element {'id':2,'name':'Mike'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.3.query.sqlpp
new file mode 100644
index 0000000..5514100
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/let33/let33.3.query.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.
+ */
+/*
+ * Description     : Test hoisting a variable that does not get inlined
+ * Expected Result : Success
+ * Date            : 8th November 2013
+ */
+
+use foo;
+
+
+with  recs as {{{'id':1,'name':'Tom'},{'id':2,'name':'Till'}}}
+select element {'name':r.name}
+from  fb as f,
+      recs as r
+where (r.name = f.name)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.3.query.sqlpp
new file mode 100644
index 0000000..ab95d27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-01/order-by-01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element a
+from  ['two','four','six','eight','ten','twenty','undo'] as a
+order by a desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.3.query.sqlpp
new file mode 100644
index 0000000..111400d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-02/order-by-02.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element a
+from  ['two','four','six','eight','ten','twenty','undo'] as a
+order by a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.3.query.sqlpp
new file mode 100644
index 0000000..4647d93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-03/order-by-03.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"([b,'test'])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as b
+order by "string-concat"([b,'test'])
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.3.query.sqlpp
new file mode 100644
index 0000000..7cd3e11
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-04/order-by-04.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"([b,'test'])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as b
+order by "string-concat"([b,'test']) desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.3.query.sqlpp
new file mode 100644
index 0000000..9d4557e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-05/order-by-05.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"([b,''])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as b
+order by "string-concat"([b,'']) desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.3.query.sqlpp
new file mode 100644
index 0000000..4736895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-06/order-by-06.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"([b,''])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as b
+order by "string-concat"([b,''])
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.3.query.sqlpp
new file mode 100644
index 0000000..65d71dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-07/order-by-07.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"(['',b])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as b
+order by "string-concat"(['',b]) desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.3.query.sqlpp
new file mode 100644
index 0000000..8e247fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-08/order-by-08.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"(['',b])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as b
+order by "string-concat"(['',b])
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.3.query.sqlpp
new file mode 100644
index 0000000..7ea38da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-09/order-by-09.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"([x,x])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as x
+order by "string-concat"([x,x])
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.3.query.sqlpp
new file mode 100644
index 0000000..c91b11a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-10/order-by-10.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element "string-concat"([x,x])
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as x
+order by "string-concat"([x,x]) desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.3.query.sqlpp
new file mode 100644
index 0000000..8131aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-11/order-by-11.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element (x + x)
+from  [1,3,4,5,2,3,33,55,43,12,34,45,67,66,89,0,-1,999] as x
+order by (x + x)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.1.ddl.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.1.ddl.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.2.update.sqlpp
new file mode 100644
index 0000000..cbef10a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.2.update.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.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.3.query.sqlpp
new file mode 100644
index 0000000..e1d2896
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/order-by-12/order-by-12.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test order by clause of FLWOR
+ * Expected Result : Success
+ * Date            : 24th July 2012
+ */
+
+select element {'x':x,'len($x)':len(x)}
+from  [[1,3,4],[5,2],[3,33,55],[43,12,34],[45,67],[66,89,0],[-1,999]] as x
+order by len(x)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.1.ddl.sqlpp
new file mode 100644
index 0000000..34fd203
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.1.ddl.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue550
+ * https://code.google.com/p/asterixdb/issues/detail?id=550
+ * Expected Result : Success
+ * Date            : 25th October 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.2.update.sqlpp
new file mode 100644
index 0000000..34fd203
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.2.update.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue550
+ * https://code.google.com/p/asterixdb/issues/detail?id=550
+ * Expected Result : Success
+ * Date            : 25th October 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.3.query.sqlpp
new file mode 100644
index 0000000..33c7947
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue550/query-issue550.3.query.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue550
+ * https://code.google.com/p/asterixdb/issues/detail?id=550
+ * Expected Result : Success
+ * Date            : 25th October 2014
+ */
+
+with  sample as {{{'r':1,'uid':'1a2b','t':datetime('2000-01-01T01:00:00'),'event':'e1'},{'r':2,'uid':'1a2b','t':datetime('2000-01-01T01:01:00'),'event':'e2'},{'r':3,'uid':'3c4d','t':datetime('2000-01-01T01:02:00'),'event':'e1'},{'r':4,'uid':'3c4d','t':datetime('2000-01-01T01:03:00'),'event':'e3'},{'r':5,'uid':'1a2b','t':datetime('2000-01-01T01:04:00'),'event':'e1'},{'r':6,'uid':'1a2b','t':datetime('2000-01-01T01:05:00'),'event':'e4'}}}
+select element {'u':u,'recs':(
+        select element srec
+        from  s as srec
+    )}
+from  sample as s
+group by s.uid as u
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.1.ddl.sqlpp
new file mode 100644
index 0000000..d510e9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.1.ddl.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue567
+ * https://code.google.com/p/asterixdb/issues/detail?id=567
+ * Expected Result : Success
+ * Date            : 16th Nov. 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.2.update.sqlpp
new file mode 100644
index 0000000..d510e9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.2.update.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue567
+ * https://code.google.com/p/asterixdb/issues/detail?id=567
+ * Expected Result : Success
+ * Date            : 16th Nov. 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.3.query.sqlpp
new file mode 100644
index 0000000..0d995c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-issue567/query-issue567.3.query.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.
+ */
+/*
+ * Description     : This test case is to verify the fix for issue567
+ * https://code.google.com/p/asterixdb/issues/detail?id=567
+ * Expected Result : Success
+ * Date            : 16th Nov. 2014
+ */
+
+with  sample as {{{'r':1,'uid':'1a2b','t':datetime('2000-01-01T01:00:00'),'event':'e1'},{'r':2,'uid':'1a2b','t':datetime('2000-01-01T01:01:00'),'event':'e2'},{'r':3,'uid':'3c4d','t':datetime('2000-01-01T01:02:00'),'event':'e1'},{'r':4,'uid':'3c4d','t':datetime('2000-01-01T01:03:00'),'event':'e3'},{'r':5,'uid':'1a2b','t':datetime('2000-01-01T01:04:00'),'event':'e1'},{'r':6,'uid':'1a2b','t':datetime('2000-01-01T01:05:00'),'event':'e4'}}}
+select element next
+from  sample as s1,
+      sample as s2
+with  pair as {'s1':s1,'s2':s2}
+where ((s1.uid = s2.uid) and (s1.t < s2.t))
+group by s1.uid,s1.t
+with  next as (
+      select element p
+      from  pair as p
+      order by p.s2.t
+      limit 1
+  )
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.2.update.sqlpp
new file mode 100644
index 0000000..684de98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.3.query.sqlpp
new file mode 100644
index 0000000..5a4165e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-01/ret-01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element "string-length"(x)
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.1.ddl.sqlpp
new file mode 100644
index 0000000..684de98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.2.update.sqlpp
new file mode 100644
index 0000000..684de98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.3.query.sqlpp
new file mode 100644
index 0000000..276ee64
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-02/ret-02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  7th July 2012
+ */
+
+select element 'this is a test string'
+from  [true] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.1.ddl.sqlpp
new file mode 100644
index 0000000..e03d8ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause 
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.2.update.sqlpp
new file mode 100644
index 0000000..e03d8ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause 
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.3.query.sqlpp
new file mode 100644
index 0000000..d9006e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-03/ret-03.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause 
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element if (true)
+    then 'YES'
+    else 'NO'
+from  [true] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.1.ddl.sqlpp
new file mode 100644
index 0000000..79fa584
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.2.update.sqlpp
new file mode 100644
index 0000000..79fa584
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.3.query.sqlpp
new file mode 100644
index 0000000..8b00113
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-04/ret-04.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Tes if expression then expression else expression in the return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+if ((12345 > 999))
+then 'GREATER'
+else 'LESSER';
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.1.ddl.sqlpp
new file mode 100644
index 0000000..6a14faf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  For + Return within return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.2.update.sqlpp
new file mode 100644
index 0000000..6a14faf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  For + Return within return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.3.query.sqlpp
new file mode 100644
index 0000000..58cee9a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-05/ret-05.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  For + Return within return clause
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element a
+from  [[1,2,3],[4,5,6,7],[8,9],[0,4,5],[6,7,1],[2,3,4],[5,6,7],[8,9,0]] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.1.ddl.sqlpp
new file mode 100644
index 0000000..aee5fa0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Return an un-ordered list
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.2.update.sqlpp
new file mode 100644
index 0000000..aee5fa0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Return an un-ordered list
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.3.query.sqlpp
new file mode 100644
index 0000000..982d672
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-06/ret-06.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ *                  :  Return an un-ordered list
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+{{'Welcome','UCI','Anteater','DBH','ICS'}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.3.query.sqlpp
new file mode 100644
index 0000000..4b31ba8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-07/ret-07.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+{};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.3.query.sqlpp
new file mode 100644
index 0000000..27fef3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-08/ret-08.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element {'a':a,'inner-for':(
+        select element b
+        from  [11,22,33,44,55,66,77,88] as b
+    )}
+from  [1,2,3,4,5,6,7,8] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.3.query.sqlpp
new file mode 100644
index 0000000..578d262
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-09/ret-09.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+1;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.3.query.sqlpp
new file mode 100644
index 0000000..4a0c848
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-10/ret-10.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element a
+from  (
+    select element b
+    from  [1,2,3,4,5,6,7,8,9,0] as b
+) as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.3.query.sqlpp
new file mode 100644
index 0000000..d2be317
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-11/ret-11.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element (a + 1)
+from  [1,2,3,4,5,6,7,8,9] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.3.query.sqlpp
new file mode 100644
index 0000000..746eb05
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-12/ret-12.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element (a - 1)
+from  [1,2,3,4,5,6,7,8,9] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.3.query.sqlpp
new file mode 100644
index 0000000..d7b38ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-13/ret-13.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+select element (a * 9)
+from  [1,2,3,4,5,6,7,8,9] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.1.ddl.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.2.update.sqlpp
new file mode 100644
index 0000000..bd80389
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.3.query.sqlpp
new file mode 100644
index 0000000..5c8d6df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-14/ret-14.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  26th July 2012
+ */
+
+{'name':'John Doe','age':26,'sex':'M','salary':50000,'dept':'HR'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.1.ddl.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.2.update.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.3.query.sqlpp
new file mode 100644
index 0000000..d1e0db1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-15/ret-15.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+((true and false) or (true and false));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.1.ddl.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.2.update.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.3.query.sqlpp
new file mode 100644
index 0000000..47f60ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-16/ret-16.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+(((100 + 100) * (34.67 / 5.324)) and ((13.4 * 14.97) / (9999 + 98677)));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.1.ddl.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.2.update.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.3.query.sqlpp
new file mode 100644
index 0000000..47f60ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-17/ret-17.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+(((100 + 100) * (34.67 / 5.324)) and ((13.4 * 14.97) / (9999 + 98677)));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.1.ddl.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.2.update.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.3.query.sqlpp
new file mode 100644
index 0000000..32ef516
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-18/ret-18.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+[1,2,3,4,5,6,7][6];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.1.ddl.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.1.ddl.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.2.update.sqlpp
new file mode 100644
index 0000000..420fb66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.2.update.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.3.query.sqlpp
new file mode 100644
index 0000000..76b21f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/ret-19/ret-19.3.query.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.
+ */
+/*
+ * Description      :  Test return clause of the FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  30th July 2012
+ */
+
+[[1,2,3,4,5,6,7],[7,8,9,10]][0];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.sqlpp
new file mode 100644
index 0000000..e52dcb4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element tokenGroupped
+from  DBLP as paper,
+      fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+group by token as tokenGroupped
+order by fuzzyjoin.count(paper),tokenGroupped
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.1.ddl.sqlpp
new file mode 100644
index 0000000..a43ffa2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.sqlpp
new file mode 100644
index 0000000..c37197b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.1.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element tokenGroupped
+from  DBLP as paper,
+      fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+with  id as paper.id
+/* +hash */
+group by token as tokenGroupped
+order by fuzzyjoin.count(id),tokenGroupped
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.1.ddl.sqlpp
new file mode 100644
index 0000000..60e8a86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.sqlpp
new file mode 100644
index 0000000..c37197b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element tokenGroupped
+from  DBLP as paper,
+      fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+with  id as paper.id
+/* +hash */
+group by token as tokenGroupped
+order by fuzzyjoin.count(id),tokenGroupped
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.1.ddl.sqlpp
new file mode 100644
index 0000000..60e8a86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.sqlpp
new file mode 100644
index 0000000..b725f9c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element tokenGroupped
+from  DBLP as paper,
+      fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+with  paperid as paper.id
+group by token as tokenGroupped
+order by fuzzyjoin.count(paperid),tokenGroupped
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.1.ddl.sqlpp
new file mode 100644
index 0000000..a821e08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.sqlpp
new file mode 100644
index 0000000..fafe488
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1_5.3.1.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'prefixToken':prefixTokenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(lenDBLP,0.500000f)) as prefixTokenDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.1.ddl.sqlpp
new file mode 100644
index 0000000..20a773e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.TOKENSRANKEDADMType as
+ closed {
+  token : int64,
+  rank : int64
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table TOKENSRANKEDADM(TOKENSRANKEDADMType) primary key rank;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.2.update.sqlpp
new file mode 100644
index 0000000..277cf7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+load  table TOKENSRANKEDADM using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/tokensranked.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.sqlpp
new file mode 100644
index 0000000..6fc2222
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'prefixToken':prefixTokenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element tokenRanked.rank
+      from  tokensUnrankedDBLP as tokenUnranked,
+            TOKENSRANKEDADM as tokenRanked
+      where (tokenUnranked = tokenRanked.token)
+      order by tokenRanked.rank
+  )
+order by idDBLP,prefixTokenDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.sqlpp
new file mode 100644
index 0000000..c5ebbed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.3.query.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':paperDBLP.id,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  tokensDBLP as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(paper),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by paperDBLP.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.sqlpp
new file mode 100644
index 0000000..13f44d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':paperDBLP.id,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  tokensDBLP as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by paperDBLP.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.sqlpp
new file mode 100644
index 0000000..1b79e24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensDBLP as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.sqlpp
new file mode 100644
index 0000000..c766a83
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.3.query.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.2.update.sqlpp
new file mode 100644
index 0000000..7ac72ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.sqlpp
new file mode 100644
index 0000000..8aad0db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.3.query.sqlpp
@@ -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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'len':lenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.sqlpp
new file mode 100644
index 0000000..8aad0db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.3.query.sqlpp
@@ -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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'len':lenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.1.ddl.sqlpp
new file mode 100644
index 0000000..a821e08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.sqlpp
new file mode 100644
index 0000000..8aad0db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.1.3.query.sqlpp
@@ -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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'len':lenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.sqlpp
new file mode 100644
index 0000000..8aad0db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.3.query.sqlpp
@@ -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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'len':lenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.sqlpp
new file mode 100644
index 0000000..56a1d3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.3.query.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'id':idDBLP,'len':lenDBLP,'tokens':tokensDBLP}
+from  DBLP as paperDBLP
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  )
+order by idDBLP
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.sqlpp
new file mode 100644
index 0000000..198c131
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.3.query.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'left':paperLeft,'right':paperRight,'sim':ridpair.sim}
+from  (
+    select element {'idLeft':idLeft,'idRight':idRight,'sim':sim[0]}
+    from  DBLP as paperLeft,
+          fuzzyjoin."subset-collection"(tokensLeft,0,fuzzyjoin."prefix-len-jaccard"(lenLeft,0.500000f)) as prefixTokenLeft,
+          DBLP as paperRight,
+          fuzzyjoin."subset-collection"(tokensRight,0,fuzzyjoin."prefix-len-jaccard"(lenRight,0.500000f)) as prefixTokenRight
+    with  lenLeft as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperLeft.title)),
+          tokensLeft as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperLeft.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              /* +hash */
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          lenRight as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperRight.title)),
+          tokensRight as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperRight.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              /* +hash */
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenLeft,tokensLeft,lenRight,tokensRight,prefixTokenLeft,0.500000f)
+    where ((prefixTokenLeft = prefixTokenRight) and ((sim >= 0.500000f) and (paperLeft.id < paperRight.id)))
+    /* +hash */
+    group by paperLeft.id as idLeft,paperRight.id as idRight
+) as ridpair,
+      DBLP as paperLeft,
+      DBLP as paperRight
+where ((ridpair.idLeft = paperLeft.id) and (ridpair.idRight = paperRight.id))
+order by paperLeft.id,paperRight.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.sqlpp
new file mode 100644
index 0000000..198c131
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.3.query.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'left':paperLeft,'right':paperRight,'sim':ridpair.sim}
+from  (
+    select element {'idLeft':idLeft,'idRight':idRight,'sim':sim[0]}
+    from  DBLP as paperLeft,
+          fuzzyjoin."subset-collection"(tokensLeft,0,fuzzyjoin."prefix-len-jaccard"(lenLeft,0.500000f)) as prefixTokenLeft,
+          DBLP as paperRight,
+          fuzzyjoin."subset-collection"(tokensRight,0,fuzzyjoin."prefix-len-jaccard"(lenRight,0.500000f)) as prefixTokenRight
+    with  lenLeft as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperLeft.title)),
+          tokensLeft as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperLeft.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              /* +hash */
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          lenRight as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperRight.title)),
+          tokensRight as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperRight.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              /* +hash */
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenLeft,tokensLeft,lenRight,tokensRight,prefixTokenLeft,0.500000f)
+    where ((prefixTokenLeft = prefixTokenRight) and ((sim >= 0.500000f) and (paperLeft.id < paperRight.id)))
+    /* +hash */
+    group by paperLeft.id as idLeft,paperRight.id as idRight
+) as ridpair,
+      DBLP as paperLeft,
+      DBLP as paperRight
+where ((ridpair.idLeft = paperLeft.id) and (ridpair.idRight = paperRight.id))
+order by paperLeft.id,paperRight.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.sqlpp
new file mode 100644
index 0000000..16fdbb2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.3.query.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'left':paperLeft,'right':paperRight,'sim':ridpair.sim}
+from  DBLP as paperLeft,
+      DBLP as paperRight,
+      (
+    select element {'idLeft':idLeft,'idRight':idRight,'sim':sim[0]}
+    from  DBLP as paperLeft,
+          fuzzyjoin."subset-collection"(tokensLeft,0,fuzzyjoin."prefix-len-jaccard"(lenLeft,0.500000f)) as prefixTokenLeft,
+          DBLP as paperRight,
+          fuzzyjoin."subset-collection"(tokensRight,0,fuzzyjoin."prefix-len-jaccard"(lenRight,0.500000f)) as prefixTokenRight
+    with  lenLeft as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperLeft.title)),
+          tokensLeft as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperLeft.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          lenRight as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperRight.title)),
+          tokensRight as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperRight.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenLeft,tokensLeft,lenRight,tokensRight,prefixTokenLeft,0.500000f)
+    where ((prefixTokenLeft = prefixTokenRight) and ((sim >= 0.500000f) and (paperLeft.id < paperRight.id)))
+    group by paperLeft.id as idLeft,paperRight.id as idRight
+) as ridpair
+where ((ridpair.idLeft = paperLeft.id) and (ridpair.idRight = paperRight.id))
+order by paperLeft.id,paperRight.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..a821e08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..71e4272
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'dblp':dblp,'dblp2':dblp2}
+from  DBLP as dblp,
+      DBLP as dblp2
+where ((fuzzyjoin."word-tokens"(dblp.title) ~= fuzzyjoin."word-tokens"(dblp2.title)) and (dblp.id < dblp2.id))
+order by dblp.id,dblp2.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..750ca8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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    : Tests that a proper error messags is returned for this scenario.
+ *                  Since we cannot statically know the type of the field 'title', the FuzzyEqRule
+ *                  cannot auto-inject a tokenizer, and hence we expect an error saying that we cannot
+ *                  scan over a string as if it were a collection.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..7417351
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.2.update.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.
+ */
+/*
+ * Description    : Tests that a proper error messags is returned for this scenario.
+ *                  Since we cannot statically know the type of the field 'title', the FuzzyEqRule
+ *                  cannot auto-inject a tokenizer, and hence we expect an error saying that we cannot
+ *                  scan over a string as if it were a collection.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+use fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..2f1743f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests that a proper error messags is returned for this scenario.
+ *                  Since we cannot statically know the type of the field 'title', the FuzzyEqRule
+ *                  cannot auto-inject a tokenizer, and hence we expect an error saying that we cannot
+ *                  scan over a string as if it were a collection.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'dblp':dblp,'dblp2':dblp2}
+from  DBLP as dblp,
+      DBLP as dblp2
+where ((dblp.title ~= dblp2.title) and (dblp.id < dblp2.id))
+order by dblp.id,dblp2.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.sqlpp
new file mode 100644
index 0000000..de3968a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.query.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  tokensDBLP as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(paper),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      tokensCSX as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperCSX.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(paper),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperDBLP.title)),tokensDBLP,fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperCSX.title)),tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+group by paperDBLP.id as idDBLP,paperCSX.id as idCSX,sim as sim
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.sqlpp
new file mode 100644
index 0000000..4f7e635
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.query.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  tokensDBLP as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      tokensCSX as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperCSX.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperDBLP.title)),tokensDBLP,fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperCSX.title)),tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+group by paperDBLP.id as idDBLP,paperCSX.id as idCSX,sim as sim
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.sqlpp
new file mode 100644
index 0000000..8add4c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.query.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensDBLP as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensCSX as (
+      select element i
+      from  fuzzyjoin."counthashed-word-tokens"(paperCSX.title) as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperDBLP.title)),tokensDBLP,fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperCSX.title)),tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.sqlpp
new file mode 100644
index 0000000..78ba1a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.query.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+      tokensCSX as (
+      select element i
+      from  tokensUnrankedCSX as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(tokensUnrankedDBLP),tokensDBLP,fuzzyjoin.len(tokensUnrankedCSX),tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.sqlpp
new file mode 100644
index 0000000..1ee0a80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.3.query.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+      lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+      tokensCSX as (
+      select element i
+      from  tokensUnrankedCSX as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+group by idDBLP as idDBLP,idCSX as idCSX
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.sqlpp
new file mode 100644
index 0000000..8070c43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.3.query.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+      lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+      tokensCSX as (
+      select element i
+      from  tokensUnrankedCSX as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+/* +hash */
+group by idDBLP as idDBLP,idCSX as idCSX
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.1.ddl.sqlpp
new file mode 100644
index 0000000..8c60970
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.sqlpp
new file mode 100644
index 0000000..78ead67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.1.3.query.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+      lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+      tokensCSX as (
+      select element i
+      from  tokensUnrankedCSX as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+/* +hash */
+group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.sqlpp
new file mode 100644
index 0000000..8070c43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.3.query.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+      lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+      tokensCSX as (
+      select element i
+      from  tokensUnrankedCSX as tokenUnranked,
+            (
+          select element tokenGrouped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          /* +hash */
+          group by token as tokenGrouped
+          order by fuzzyjoin.count(id),tokenGrouped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+/* +hash */
+group by idDBLP as idDBLP,idCSX as idCSX
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.sqlpp
new file mode 100644
index 0000000..1f819a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.query.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+from  DBLP as paperDBLP,
+      fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+      CSX as paperCSX,
+      fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+with  idDBLP as paperDBLP.id,
+      tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+      lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+      tokensDBLP as (
+      select element i
+      from  tokensUnrankedDBLP as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      idCSX as paperCSX.id,
+      tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+      lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+      tokensCSX as (
+      select element i
+      from  tokensUnrankedCSX as tokenUnranked,
+            (
+          select element tokenGroupped
+          from  DBLP as paper,
+                fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+          with  id as paper.id
+          group by token as tokenGroupped
+          order by fuzzyjoin.count(id),tokenGroupped
+      ) as tokenRanked at i
+      where (tokenUnranked = tokenRanked)
+      order by i
+  ),
+      sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+order by idDBLP,idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.sqlpp
new file mode 100644
index 0000000..9e450e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.query.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  tokensDBLP as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          tokensCSX as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperCSX.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperDBLP.title)),tokensDBLP,fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperCSX.title)),tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    group by paperDBLP.id as idDBLP,paperCSX.id as idCSX,sim as sim
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.sqlpp
new file mode 100644
index 0000000..7201067
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.query.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  tokensDBLP as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          tokensCSX as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperCSX.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperDBLP.title)),tokensDBLP,fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperCSX.title)),tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    group by paperDBLP.id as idDBLP,paperCSX.id as idCSX,sim as sim
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.sqlpp
new file mode 100644
index 0000000..a55a959
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.query.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensDBLP as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperDBLP.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensCSX as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperCSX.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperDBLP.title)),tokensDBLP,fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperCSX.title)),tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.sqlpp
new file mode 100644
index 0000000..1385854
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.query.sqlpp
@@ -0,0 +1,72 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+          tokensDBLP as (
+          select element i
+          from  tokensUnrankedDBLP as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+          tokensCSX as (
+          select element i
+          from  tokensUnrankedCSX as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(fuzzyjoin.len(tokensUnrankedDBLP),tokensDBLP,fuzzyjoin.len(tokensUnrankedCSX),tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.sqlpp
new file mode 100644
index 0000000..6ad53f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.3.query.sqlpp
@@ -0,0 +1,76 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+          lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+          tokensDBLP as (
+          select element i
+          from  tokensUnrankedDBLP as tokenUnranked,
+                (
+              select element tokenGrouped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGrouped
+              order by fuzzyjoin.count(id),tokenGrouped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+          lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+          tokensCSX as (
+          select element i
+          from  tokensUnrankedCSX as tokenUnranked,
+                (
+              select element tokenGrouped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGrouped
+              order by fuzzyjoin.count(id),tokenGrouped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    group by idDBLP as idDBLP,idCSX as idCSX
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.sqlpp
new file mode 100644
index 0000000..3b84499
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.3.query.sqlpp
@@ -0,0 +1,77 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+          lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+          tokensDBLP as (
+          select element i
+          from  tokensUnrankedDBLP as tokenUnranked,
+                (
+              select element tokenGrouped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGrouped
+              order by fuzzyjoin.count(id),tokenGrouped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+          lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+          tokensCSX as (
+          select element i
+          from  tokensUnrankedCSX as tokenUnranked,
+                (
+              select element tokenGrouped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGrouped
+              order by fuzzyjoin.count(id),tokenGrouped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    /* +hash */
+    group by idDBLP as idDBLP,idCSX as idCSX
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.sqlpp
new file mode 100644
index 0000000..3b84499
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.1.3.query.sqlpp
@@ -0,0 +1,77 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+          lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+          tokensDBLP as (
+          select element i
+          from  tokensUnrankedDBLP as tokenUnranked,
+                (
+              select element tokenGrouped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGrouped
+              order by fuzzyjoin.count(id),tokenGrouped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+          lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+          tokensCSX as (
+          select element i
+          from  tokensUnrankedCSX as tokenUnranked,
+                (
+              select element tokenGrouped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGrouped
+              order by fuzzyjoin.count(id),tokenGrouped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    /* +hash */
+    group by idDBLP as idDBLP,idCSX as idCSX
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.sqlpp
new file mode 100644
index 0000000..d23af3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.3.query.sqlpp
@@ -0,0 +1,77 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+          lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+          tokensDBLP as (
+          select element i
+          from  tokensUnrankedDBLP as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+          lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+          tokensCSX as (
+          select element i
+          from  tokensUnrankedCSX as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              /* +hash */
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    /* +hash */
+    group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.sqlpp
new file mode 100644
index 0000000..38bb511
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.4.1.3.query.sqlpp
@@ -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.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLPridpair.paperDBLP,'csx':paperCSX,'sim':paperDBLPridpair.sim}
+from  CSX as paperCSX,
+      (
+    select element {'idDBLP':paperDBLP.id,'idCSX':ridpair.idCSX,'paperDBLP':paperDBLP,'sim':ridpair.sim}
+    from  DBLP as paperDBLP,
+          (
+        select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+        from  DBLP as paperDBLP,
+              fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+              CSX as paperCSX,
+              fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+        with  idDBLP as paperDBLP.id,
+              tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+              lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+              tokensDBLP as (
+              select element i
+              from  tokensUnrankedDBLP as tokenUnranked,
+                    (
+                  select element tokenGrouped
+                  from  DBLP as paper,
+                        fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+                  with  id as paper.id
+                  /* +hash */
+                  group by token as tokenGrouped
+                  order by fuzzyjoin.count(id),tokenGrouped
+              ) as tokenRanked at i
+              where (tokenUnranked = tokenRanked)
+              order by i
+          ),
+              idCSX as paperCSX.id,
+              tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+              lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+              tokensCSX as (
+              select element i
+              from  tokensUnrankedCSX as tokenUnranked,
+                    (
+                  select element tokenGrouped
+                  from  DBLP as paper,
+                        fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+                  with  id as paper.id
+                  /* +hash */
+                  group by token as tokenGrouped
+                  order by fuzzyjoin.count(id),tokenGrouped
+              ) as tokenRanked at i
+              where (tokenUnranked = tokenRanked)
+              order by i
+          ),
+              sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+        where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+        /* +hash */
+        group by idDBLP as idDBLP,idCSX as idCSX
+    ) as ridpair
+    where (ridpair.idDBLP = paperDBLP.id)
+) as paperDBLPridpair
+where (paperDBLPridpair.idCSX = paperCSX.id)
+order by paperDBLPridpair.idDBLP,paperDBLPridpair.idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.sqlpp
new file mode 100644
index 0000000..7eb3ce5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.4.3.query.sqlpp
@@ -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.
+ */
+
+use fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLPridpair.paperDBLP,'csx':paperCSX,'sim':paperDBLPridpair.sim}
+from  CSX as paperCSX,
+      (
+    select element {'idDBLP':paperDBLP.id,'paperDBLP':paperDBLP,'idCSX':ridpair.idCSX,'sim':ridpair.sim}
+    from  DBLP as paperDBLP,
+          (
+        select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+        from  DBLP as paperDBLP,
+              fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+              CSX as paperCSX,
+              fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+        with  idDBLP as paperDBLP.id,
+              tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+              lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+              tokensDBLP as (
+              select element i
+              from  tokensUnrankedDBLP as tokenUnranked,
+                    (
+                  select element tokenGrouped
+                  from  DBLP as paper,
+                        fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+                  with  id as paper.id
+                  /* +hash */
+                  group by token as tokenGrouped
+                  order by fuzzyjoin.count(id),tokenGrouped
+              ) as tokenRanked at i
+              where (tokenUnranked = tokenRanked)
+              order by i
+          ),
+              idCSX as paperCSX.id,
+              tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+              lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+              tokensCSX as (
+              select element i
+              from  tokensUnrankedCSX as tokenUnranked,
+                    (
+                  select element tokenGrouped
+                  from  DBLP as paper,
+                        fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+                  with  id as paper.id
+                  /* +hash */
+                  group by token as tokenGrouped
+                  order by fuzzyjoin.count(id),tokenGrouped
+              ) as tokenRanked at i
+              where (tokenUnranked = tokenRanked)
+              order by i
+          ),
+              sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+        where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+        /* +hash */
+        group by idDBLP as idDBLP,idCSX as idCSX
+    ) as ridpair
+    where (ridpair.idDBLP = paperDBLP.id)
+) as paperDBLPridpair
+where (paperDBLPridpair.idCSX = paperCSX.id)
+order by paperDBLPridpair.paperDBLP.id,paperDBLPridpair.idCSX
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.sqlpp
new file mode 100644
index 0000000..a7df571
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.query.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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 fuzzyjoin;
+
+
+set "import-private-functions" "true";
+
+select element {'dblp':paperDBLP,'csx':paperCSX,'sim':ridpair.sim}
+from  (
+    select element {'idDBLP':idDBLP,'idCSX':idCSX,'sim':sim[0]}
+    from  DBLP as paperDBLP,
+          fuzzyjoin."subset-collection"(tokensDBLP,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensDBLP),0.500000f)) as prefixTokenDBLP,
+          CSX as paperCSX,
+          fuzzyjoin."subset-collection"(tokensCSX,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensCSX),0.500000f)) as prefixTokenCSX
+    with  idDBLP as paperDBLP.id,
+          tokensUnrankedDBLP as fuzzyjoin."counthashed-word-tokens"(paperDBLP.title),
+          lenDBLP as fuzzyjoin.len(tokensUnrankedDBLP),
+          tokensDBLP as (
+          select element i
+          from  tokensUnrankedDBLP as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          idCSX as paperCSX.id,
+          tokensUnrankedCSX as fuzzyjoin."counthashed-word-tokens"(paperCSX.title),
+          lenCSX as fuzzyjoin.len(tokensUnrankedCSX),
+          tokensCSX as (
+          select element i
+          from  tokensUnrankedCSX as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              with  id as paper.id
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(id),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenDBLP,tokensDBLP,lenCSX,tokensCSX,prefixTokenDBLP,0.500000f)
+    where ((prefixTokenDBLP = prefixTokenCSX) and (sim >= 0.500000f))
+    group by idDBLP as idDBLP,idCSX as idCSX,sim as sim
+) as ridpair,
+      DBLP as paperDBLP,
+      CSX as paperCSX
+where ((ridpair.idDBLP = paperDBLP.id) and (ridpair.idCSX = paperCSX.id))
+order by paperDBLP.id,paperCSX.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..148e5ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'dblp':i,'csx':j}
+from  DBLP as i,
+      CSX as j
+where (fuzzyjoin."word-tokens"(i.title) ~= fuzzyjoin."word-tokens"(j.title))
+order by i.id,j.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..3532c8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'dblp':dblp,'csx':csx}
+from  CSX as csx,
+      DBLP as dblp
+where (fuzzyjoin."word-tokens"(dblp.title) ~= fuzzyjoin."word-tokens"(csx.title))
+order by dblp.id,csx.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.3.query.sqlpp
new file mode 100644
index 0000000..09ba2c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'dblp':dblp,'csx':csx}
+from  DBLP as dblp,
+      CSX as csx
+where (fuzzyjoin."word-tokens"(csx.title) ~= fuzzyjoin."word-tokens"(dblp.title))
+order by dblp.id,csx.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..1d58050
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.1.ddl.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.
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type fuzzyjoin.CSXType as
+{
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..28f8015
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..d59a232
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'dblp':dblp,'csx':csx,'dblp2':dblp2}
+from  DBLP as dblp,
+      CSX as csx,
+      DBLP as dblp2
+where ((fuzzyjoin."word-tokens"(dblp.title) ~= fuzzyjoin."word-tokens"(csx.title)) and (fuzzyjoin."word-tokens"(csx.authors) ~= fuzzyjoin."word-tokens"(dblp2.authors)))
+order by dblp.id,csx.id,dblp2.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.1.ddl.sqlpp
new file mode 100644
index 0000000..710e955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.2.update.sqlpp
new file mode 100644
index 0000000..312a2c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.2.update.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 fuzzyjoin;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.3.query.sqlpp
new file mode 100644
index 0000000..2c78aa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+select element paper
+from  DBLP as paper
+where (paper.id = 1)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.1.ddl.sqlpp
new file mode 100644
index 0000000..c7f33d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create external  table DBLP(DBLPType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.2.update.sqlpp
new file mode 100644
index 0000000..d60abe9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.2.update.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 fuzzyjoin;
+
+
+create external  table DBLP(DBLPType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.3.query.sqlpp
new file mode 100644
index 0000000..57d1c18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/dblp-splits-3_1/dblp-splits-3_1.3.query.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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 fuzzyjoin;
+
+
+select element {'left':paperLeft,'right':paperRight,'sim':ridpair.sim}
+from  (
+    select element {'idLeft':idLeft,'idRight':idRight,'sim':sim[0]}
+    from  DBLP as paperLeft,
+          fuzzyjoin."subset-collection"(tokensLeft,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensLeft),0.500000f)) as prefix_tokenLeft,
+          DBLP as paperRight,
+          fuzzyjoin."subset-collection"(tokensRight,0,fuzzyjoin."prefix-len-jaccard"(fuzzyjoin.len(tokensRight),0.500000f)) as prefix_tokenRight
+    with  lenLeft as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperLeft.title)),
+          tokensLeft as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperLeft.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          lenRight as fuzzyjoin.len(fuzzyjoin."counthashed-word-tokens"(paperRight.title)),
+          tokensRight as (
+          select element i
+          from  fuzzyjoin."counthashed-word-tokens"(paperRight.title) as tokenUnranked,
+                (
+              select element tokenGroupped
+              from  DBLP as paper,
+                    fuzzyjoin."counthashed-word-tokens"(paper.title) as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(paper),tokenGroupped
+          ) as tokenRanked at i
+          where (tokenUnranked = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenLeft,tokensLeft,lenRight,tokensRight,prefix_tokenLeft,0.500000f)
+    where ((prefix_tokenLeft = prefix_tokenRight) and ((sim >= 0.500000f) and (paperLeft.id < paperRight.id)))
+    group by paperLeft.id as idLeft,paperRight.id as idRight
+) as ridpair,
+      DBLP as paperLeft,
+      DBLP as paperRight
+where ((ridpair.idLeft = paperLeft.id) and (ridpair.idRight = paperRight.id))
+order by paperLeft.id,paperRight.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..7bdb6a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.AddressType as
+ closed {
+  street : string,
+  city : string,
+  zip : string,
+  latlong : point
+}
+
+create type fuzzyjoin.UserType as
+{
+  name : string,
+  interests : {{string}},
+  address : AddressType,
+  member_of : {{{
+          sig_id : int64,
+          chapter_name : string,
+          member_since : date
+      }
+}}
+}
+
+create  table User(UserType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..4e2cea3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.2.update.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 fuzzyjoin;
+
+
+load  table User using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/events/tiny/user.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..b7a636c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/events-users-aqlplus_1/events-users-aqlplus_1.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user_name':user.name,'similar_users':similar_users}
+from  User as user
+with  similar_users as (
+      select element {'user_name':similar_user.name}
+      from  User as similar_user
+      where (user.interests ~= similar_user.interests)
+      order by similar_user.name
+  )
+order by user.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.1.ddl.sqlpp
new file mode 100644
index 0000000..5744e1f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.1.ddl.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.
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TweetMessageType as
+{
+  tweetid : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.2.update.sqlpp
new file mode 100644
index 0000000..939730e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.3.query.sqlpp
new file mode 100644
index 0000000..96aa6d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/opentype/opentype.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 TinySocial;
+
+
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.3";
+
+select element {'tweet':t,'similar-tweets':(
+        select element t2."referred-topics"
+        from  TweetMessages as t2
+        where ((t2."referred-topics" ~= t."referred-topics") and (t2.tweetid != t.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t
+order by t.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..f7f0a47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.2.update.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 fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..c6cc242
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_1/user-int-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2}
+from  Users as user,
+      Users as user2
+where ((user.interests ~= user2.interests) and (user.uid < user2.uid))
+order by user.uid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..f7f0a47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.2.update.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 fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..2836af5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_2/user-int-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2}
+from  Users as user2,
+      Users as user
+where ((user.interests ~= user2.interests) and (user.uid < user2.uid))
+order by user.uid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.2.update.sqlpp
new file mode 100644
index 0000000..423f410
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.3.query.sqlpp
new file mode 100644
index 0000000..e8edbd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-int-aqlplus_3/user-int-aqlplus_3.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2}
+from  Users as user,
+      Users as user2
+where ((user2.interests ~= user.interests) and (user.uid < user2.uid))
+order by user.uid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.2.update.sqlpp
new file mode 100644
index 0000000..f7f0a47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.2.update.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 fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.3.query.sqlpp
new file mode 100644
index 0000000..f15d64c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1.1/user-lot-aqlplus_1.1.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2,'sim':sim}
+from  Users as user,
+      Users as user2
+with  sim as fuzzyjoin."similarity-jaccard"(user.lottery_numbers,user2.lottery_numbers)
+where ((user.lottery_numbers ~= user2.lottery_numbers) and (user.uid < user2.uid))
+order by sim desc,user.uid,user2.uid
+limit 3
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..f7f0a47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.2.update.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 fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..ad77a3c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_1/user-lot-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2}
+from  Users as user,
+      Users as user2
+where ((user.lottery_numbers ~= user2.lottery_numbers) and (user.uid < user2.uid))
+order by user.uid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..f7f0a47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.2.update.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 fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..4469c07
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_2/user-lot-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2}
+from  Users as user2,
+      Users as user
+where ((user.lottery_numbers ~= user2.lottery_numbers) and (user.uid < user2.uid))
+order by user.uid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.1.ddl.sqlpp
new file mode 100644
index 0000000..2abf624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.2.update.sqlpp
new file mode 100644
index 0000000..f7f0a47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.2.update.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 fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.3.query.sqlpp
new file mode 100644
index 0000000..0dc249f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-lot-aqlplus_3/user-lot-aqlplus_3.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'user2':user2}
+from  Users as user,
+      Users as user2
+where ((user2.lottery_numbers ~= user.lottery_numbers) and (user.uid < user2.uid))
+order by user.uid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.3.query.sqlpp
new file mode 100644
index 0000000..a720341
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-3_1/user-vis-int-3_1.3.query.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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 fuzzyjoin;
+
+
+select element {'user':user,'visitor':visitor,'sim':ridpair.sim}
+from  (
+    select element {'uid':uid,'vid':vid,'sim':sim[0]}
+    from  Users as user,
+          fuzzyjoin."subset-collection"(tokensUser,0,fuzzyjoin."prefix-len-jaccard"(lenUser,0.500000f)) as prefixTokenUser,
+          Visitors as visitor,
+          fuzzyjoin."subset-collection"(tokensVisitor,0,fuzzyjoin."prefix-len-jaccard"(lenVisitor,0.500000f)) as prefixTokenVisitor
+    with  lenUser as fuzzyjoin.len(user.interests),
+          tokensUser as (
+          select element i
+          from  user.interests as token,
+                (
+              select element tokenGroupped
+              from  Users as user,
+                    user.interests as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(user),tokenGroupped
+          ) as tokenRanked at i
+          where (token = tokenRanked)
+          order by i
+      ),
+          lenVisitor as fuzzyjoin.len(visitor.interests),
+          tokensVisitor as (
+          select element i
+          from  visitor.interests as token,
+                (
+              select element tokenGroupped
+              from  Users as user,
+                    user.interests as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(user),tokenGroupped
+          ) as tokenRanked at i
+          where (token = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenUser,tokensUser,lenVisitor,tokensVisitor,prefixTokenUser,0.500000f)
+    where ((prefixTokenUser = prefixTokenVisitor) and (sim >= 0.500000f))
+    group by user.uid as uid,visitor.vid as vid
+) as ridpair,
+      Users as user,
+      Visitors as visitor
+where ((ridpair.uid = user.uid) and (ridpair.vid = visitor.vid))
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..ac7d293
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_1/user-vis-int-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where (user.interests ~= visitor.interests)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..81d9cbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_2/user-vis-int-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Visitors as visitor,
+      Users as user
+where (user.interests ~= visitor.interests)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.3.query.sqlpp
new file mode 100644
index 0000000..bbd7587
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-aqlplus_3/user-vis-int-aqlplus_3.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where (visitor.interests ~= user.interests)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..482d5e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-int-vis-user-lot-aqlplus_1/user-vis-int-vis-user-lot-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor,'user2':user2}
+from  Users as user,
+      Visitors as visitor,
+      Users as user2
+where ((user.interests ~= visitor.interests) and (visitor.lottery_numbers ~= user2.lottery_numbers))
+order by user.uid,visitor.vid,user2.uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.3.query.sqlpp
new file mode 100644
index 0000000..c7e21af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-3_1/user-vis-lot-3_1.3.query.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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 fuzzyjoin;
+
+
+select element {'user':user,'visitor':visitor,'sim':ridpair.sim}
+from  (
+    select element {'uid':uid,'vid':vid,'sim':sim[0]}
+    from  Users as user,
+          fuzzyjoin."subset-collection"(tokensUser,0,fuzzyjoin."prefix-len-jaccard"(lenUser,0.500000f)) as prefixTokenUser,
+          Visitors as visitor,
+          fuzzyjoin."subset-collection"(tokensVisitor,0,fuzzyjoin."prefix-len-jaccard"(lenVisitor,0.500000f)) as prefixTokenVisitor
+    with  lenUser as fuzzyjoin.len(user.lottery_numbers),
+          tokensUser as (
+          select element i
+          from  user.lottery_numbers as token,
+                (
+              select element tokenGroupped
+              from  Users as user,
+                    user.lottery_numbers as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(user)
+          ) as tokenRanked at i
+          where (token = tokenRanked)
+          order by i
+      ),
+          lenVisitor as fuzzyjoin.len(visitor.lottery_numbers),
+          tokensVisitor as (
+          select element i
+          from  visitor.lottery_numbers as token,
+                (
+              select element tokenGroupped
+              from  Users as user,
+                    user.lottery_numbers as token
+              group by token as tokenGroupped
+              order by fuzzyjoin.count(user)
+          ) as tokenRanked at i
+          where (token = tokenRanked)
+          order by i
+      ),
+          sim as fuzzyjoin."similarity-jaccard-prefix"(lenUser,tokensUser,lenVisitor,tokensVisitor,prefixTokenUser,0.500000f)
+    where ((prefixTokenUser = prefixTokenVisitor) and (sim >= 0.500000f))
+    group by user.uid as uid,visitor.vid as vid
+) as ridpair,
+      Users as user,
+      Visitors as visitor
+where ((ridpair.uid = user.uid) and (ridpair.vid = visitor.vid))
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..9d71ac3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_1/user-vis-lot-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where (user.lottery_numbers ~= visitor.lottery_numbers)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..1e9d396
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_2/user-vis-lot-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Visitors as visitor,
+      Users as user
+where (user.lottery_numbers ~= visitor.lottery_numbers)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.3.query.sqlpp
new file mode 100644
index 0000000..06de258
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_3/user-vis-lot-aqlplus_3.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where (visitor.lottery_numbers ~= user.lottery_numbers)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.3.query.sqlpp
new file mode 100644
index 0000000..40440ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_4/user-vis-lot-aqlplus_4.3.query.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.
+ */
+
+use fuzzyjoin;
+
+
+set "simfunction" "Jaccard";
+
+set "simthreshold" ".6f";
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where (user.lottery_numbers ~= visitor.lottery_numbers)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.3.query.sqlpp
new file mode 100644
index 0000000..8585a32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-aqlplus_5/user-vis-lot-aqlplus_5.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where (user.lottery_numbers ~= visitor.lottery_numbers)
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.3.query.sqlpp
new file mode 100644
index 0000000..2f7bdaf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_1/user-vis-lot-int-aqlplus_1.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Users as user,
+      Visitors as visitor
+where ((user.lottery_numbers ~= visitor.lottery_numbers) and (user.interests ~= visitor.interests))
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.1.ddl.sqlpp
new file mode 100644
index 0000000..18a7240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type fuzzyjoin.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.2.update.sqlpp
new file mode 100644
index 0000000..eb6dd91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.2.update.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.
+ */
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.3.query.sqlpp
new file mode 100644
index 0000000..f3f3f32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/fuzzyjoin/user-vis-lot-int-aqlplus_2/user-vis-lot-int-aqlplus_2.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use fuzzyjoin;
+
+
+set "simthreshold" ".5f";
+
+select element {'user':user,'visitor':visitor}
+from  Visitors as visitor,
+      Users as user
+where ((user.lottery_numbers ~= visitor.lottery_numbers) and (user.interests ~= visitor.interests))
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.1.ddl.sqlpp
new file mode 100644
index 0000000..b20320b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 Pregelix if exists;
+create  database Pregelix;
+
+use Pregelix;
+
+
+create type Pregelix.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type Pregelix.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  "retweeted-from" : int64,
+  "forwarded-from" : int64
+}
+
+create  table TwitterMsgs(TweetMessageType) primary key tweetid;
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create type Pregelix.TMEdge as
+{
+  tweetid : int64,
+  "value" : float?
+}
+
+create type Pregelix.TMGraph as
+{
+  tweetid : int64,
+  "rank-value" : double?,
+  "populated-by" : {{TMEdge}}
+}
+
+create  table MyInputGraph(TMGraph) primary key tweetid;
+
+create  table MyOutputGraph(TMGraph) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.2.update.sqlpp
new file mode 100644
index 0000000..8bd8c45
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use Pregelix;
+
+
+insert into TwitterUsers
+select element {{{'screen-name':'NathanGiesen@211','lang':'en','friends_count':18,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},{'screen-name':'ColineGeyer@63','lang':'en','friends_count':121,'statuses_count':362,'name':'Coline Geyer','followers_count':17159},{'screen-name':'NilaMilliron_tw','lang':'en','friends_count':445,'statuses_count':164,'name':'Nila Milliron','followers_count':22649},{'screen-name':'ChangEwing_573','lang':'en','friends_count':182,'statuses_count':394,'name':'Chang Ewing','followers_count':32136}}};
+insert into TwitterMsgs
+select element {{{'tweetid':1,'user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':Pregelix.point('47.44,80.65'),'send-time':Pregelix.datetime('2008-04-26T10:10:00'),'referred-topics':{{'t-mobile','customization'}},'message-text':' love t-mobile its customization is good:)','retweeted-from':2,'forwarded-from':3},{'tweetid':2,'user':{'screen-name':'ColineGeyer@63','lang':'en','friends_count':121,'statuses_count':362,'name':'Coline Geyer','followers_count':17159},'sender-location':Pregelix.point('32.84,67.14'),'send-time':Pregelix.datetime('2010-05-13T10:10:00'),'referred-topics':{{'verizon','shortcut-menu'}},'message-text':' like verizon its shortcut-menu is awesome:)','retweeted-from':7,'forwarded-from':1},{'tweetid':3,'user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':Pregelix.point('29.72,75.8'),'send-time':Pregelix.datetime('2006-11-04T10:10:00'),'referred-topics':{{'motorola','speed'}},'message-text':' like motorola the speed is good:)','retweeted-from':8,'forwarded-from':6},{'tweetid':4,'user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':Pregelix.point('39.28,70.48'),'send-time':Pregelix.datetime('2011-12-26T10:10:00'),'referred-topics':{{'sprint','voice-command'}},'message-text':' like sprint the voice-command is mind-blowing:)','retweeted-from':1,'forwarded-from':3},{'tweetid':5,'user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':Pregelix.point('40.09,92.69'),'send-time':Pregelix.datetime('2006-08-04T10:10:00'),'referred-topics':{{'motorola','speed'}},'message-text':' can\'t stand motorola its speed is terrible:(','retweeted-from':8,'forwarded-from':6},{'tweetid':6,'user':{'screen-name':'ColineGeyer@63','lang':'en','friends_count':121,'statuses_count':362,'name':'Coline Geyer','followers_count':17159},'sender-location':Pregelix.point('47.51,83.99'),'send-time':Pregelix.datetime('2010-05-07T10:10:00'),'referred-topics':{{'iphone','voice-clarity'}},'message-text':' like iphone the voice-clarity is good:)','retweeted-from':4,'forwarded-from':5},{'tweetid':7,'user':{'screen-name':'ChangEwing_573','lang':'en','friends_count':182,'statuses_count':394,'name':'Chang Ewing','followers_count':32136},'sender-location':Pregelix.point('36.21,72.6'),'send-time':Pregelix.datetime('2011-08-25T10:10:00'),'referred-topics':{{'samsung','platform'}},'message-text':' like samsung the platform is good','retweeted-from':2,'forwarded-from':7},{'tweetid':8,'user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':Pregelix.point('46.05,93.34'),'send-time':Pregelix.datetime('2005-10-14T10:10:00'),'referred-topics':{{'t-mobile','shortcut-menu'}},'message-text':' like t-mobile the shortcut-menu is awesome:)','retweeted-from':3,'forwarded-from':7},{'tweetid':9,'user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':Pregelix.point('36.86,74.62'),'send-time':Pregelix.datetime('2012-07-21T10:10:00'),'referred-topics':{{'verizon','voicemail-service'}},'message-text':' love verizon its voicemail-service is awesome','retweeted-from':6,'forwarded-from':2},{'tweetid':10,'user':{'screen-name':'ColineGeyer@63','lang':'en','friends_count':121,'statuses_count':362,'name':'Coline Geyer','followers_count':17159},'sender-location':Pregelix.point('29.15,76.53'),'send-time':Pregelix.datetime('2008-01-26T10:10:00'),'referred-topics':{{'verizon','voice-clarity'}},'message-text':' hate verizon its voice-clarity is OMG:(','retweeted-from':4,'forwarded-from':5},{'tweetid':11,'user':{'screen-name':'NilaMilliron_tw','lang':'en','friends_count':445,'statuses_count':164,'name':'Nila Milliron','followers_count':22649},'sender-location':Pregelix.point('37.59,68.42'),'send-time':Pregelix.datetime('2008-03-09T10:10:00'),'referred-topics':{{'iphone','platform'}},'message-text':' can\'t stand iphone its platform is terrible','retweeted-from':6,'forwarded-from':3},{'tweetid':12,'user':{'screen-name':'OliJackson_512','lang':'en','friends_count':445,'statuses_count':164,'name':'Oli Jackson','followers_count':22649},'sender-location':Pregelix.point('24.82,94.63'),'send-time':Pregelix.datetime('2010-02-13T10:10:00'),'referred-topics':{{'samsung','voice-command'}},'message-text':' like samsung the voice-command is amazing:)','retweeted-from':6,'forwarded-from':5}}};
+insert into MyInputGraph
+select element {'tweetid':tm.tweetid,'rank-value':0.0,'populated-by':links}
+from  TwitterMsgs as tm
+with  links as {{{'tweetid':tm."retweeted-from"},{'tweetid':tm."forwarded-from"}}}
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.3.query.sqlpp
new file mode 100644
index 0000000..0a70a27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q01/pregel-q01.3.query.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 Pregelix;
+
+
+select element n
+from  MyOutputGraph as n
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.1.ddl.sqlpp
new file mode 100644
index 0000000..63bf21a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 Pregelix if exists;
+create  database Pregelix;
+
+use Pregelix;
+
+
+create type Pregelix.EdgeType as
+{
+  destVertexId : int64,
+  "value" : float?
+}
+
+create type Pregelix.NodeType as
+{
+  id : int64,
+  "value" : int64?,
+  edges : {{EdgeType}}
+}
+
+create  table InputGraph(NodeType) primary key id;
+
+create  table ResultGraph(NodeType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.2.update.sqlpp
new file mode 100644
index 0000000..2ec9add
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.2.update.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 Pregelix;
+
+
+insert into InputGraph
+select element {{{'id':0,'value':0,'edges':{{{'destVertexId':1}}}},{'id':1,'value':1,'edges':{{{'destVertexId':1},{'destVertexId':2}}}},{'id':2,'value':2,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3}}}},{'id':3,'value':3,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4}}}},{'id':4,'value':4,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4},{'destVertexId':5}}}},{'id':5,'value':5,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4},{'destVertexId':5},{'destVertexId':6}}}},{'id':6,'value':6,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4},{'destVertexId':5},{'destVertexId':6},{'destVertexId':7}}}},{'id':7,'value':7,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4},{'destVertexId':5},{'destVertexId':6},{'destVertexId':7},{'destVertexId':8}}}},{'id':8,'value':8,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4},{'destVertexId':5},{'destVertexId':6},{'destVertexId':7},{'destVertexId':8},{'destVertexId':9}}}},{'id':9,'value':9,'edges':{{{'destVertexId':1},{'destVertexId':2},{'destVertexId':3},{'destVertexId':4},{'destVertexId':5},{'destVertexId':6},{'destVertexId':7},{'destVertexId':8},{'destVertexId':9},{'destVertexId':0}}}},{'id':10,'value':10,'edges':{{{'destVertexId':11}}}},{'id':11,'value':11,'edges':{{{'destVertexId':11},{'destVertexId':12}}}},{'id':12,'value':12,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13}}}},{'id':13,'value':13,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14}}}},{'id':14,'value':14,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14},{'destVertexId':15}}}},{'id':15,'value':15,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14},{'destVertexId':15},{'destVertexId':16}}}},{'id':16,'value':16,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14},{'destVertexId':15},{'destVertexId':16},{'destVertexId':17}}}},{'id':17,'value':17,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14},{'destVertexId':15},{'destVertexId':16},{'destVertexId':17},{'destVertexId':18}}}},{'id':18,'value':18,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14},{'destVertexId':15},{'destVertexId':16},{'destVertexId':17},{'destVertexId':18},{'destVertexId':19}}}},{'id':19,'value':19,'edges':{{{'destVertexId':11},{'destVertexId':12},{'destVertexId':13},{'destVertexId':14},{'destVertexId':15},{'destVertexId':16},{'destVertexId':17},{'destVertexId':18},{'destVertexId':19},{'destVertexId':10}}}}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.3.query.sqlpp
new file mode 100644
index 0000000..99f49c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q02/pregel-q02.3.query.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 Pregelix;
+
+
+select element n
+from  ResultGraph as n
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.1.ddl.sqlpp
new file mode 100644
index 0000000..9e97505
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 Pregelix if exists;
+create  database Pregelix;
+
+use Pregelix;
+
+
+create type Pregelix.EdgeType as
+{
+  destVertexId : int64,
+  cost : float?
+}
+
+create type Pregelix.NodeType as
+{
+  id : int64,
+  "value" : double?,
+  edges : {{EdgeType}}
+}
+
+create  table InputGraph(NodeType) primary key id;
+
+create  table ResultGraph(NodeType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.2.update.sqlpp
new file mode 100644
index 0000000..6b89842
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.2.update.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 Pregelix;
+
+
+insert into InputGraph
+select element {{{'id':0,'edges':{{{'destVertexId':1,'cost':1.000000f}}}},{'id':1,'edges':{{{'destVertexId':3,'cost':4.000000f},{'destVertexId':2,'cost':3.000000f}}}},{'id':2,'edges':{{{'destVertexId':4,'cost':5.000000f},{'destVertexId':5,'cost':23.000000f}}}},{'id':3,'edges':{{{'destVertexId':2,'cost':1.000000f},{'destVertexId':8,'cost':13.000000f}}}},{'id':4,'edges':{{{'destVertexId':1,'cost':5.000000f},{'destVertexId':2,'cost':8.000000f},{'destVertexId':3,'cost':23.000000f},{'destVertexId':4,'cost':12.000000f}}}},{'id':5,'edges':{{{'destVertexId':6,'cost':12.000000f},{'destVertexId':7,'cost':17.000000f}}}},{'id':6,'edges':{{{'destVertexId':1,'cost':12.000000f},{'destVertexId':2,'cost':1.000000f}}}},{'id':7,'edges':{{{'destVertexId':9,'cost':100.000000f}}}},{'id':8,'edges':{{{'destVertexId':4,'cost':11.000000f}}}},{'id':9,'edges':{{{'destVertexId':1,'cost':16.000000f},{'destVertexId':2,'cost':9.000000f}}}}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.3.query.sqlpp
new file mode 100644
index 0000000..99f49c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/graph/pregel-q03/pregel-q03.3.query.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 Pregelix;
+
+
+select element n
+from  ResultGraph as n
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.1.ddl.sqlpp
new file mode 100644
index 0000000..8cb8ca6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.1.ddl.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  content : string
+}
+
+create external  table TextDataset(LineType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/textFileS"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"="."));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.2.update.sqlpp
new file mode 100644
index 0000000..7054391
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.3.query.sqlpp
new file mode 100644
index 0000000..7892d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_02/hdfs_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
+use test;
+
+
+select element {'word':tok,'count':test.count(token)}
+from  TextDataset as line,
+      tokens as token
+with  tokens as test."word-tokens"(line.content)
+group by token as tok
+order by tok
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.1.ddl.sqlpp
new file mode 100644
index 0000000..5172723
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.1.ddl.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a large (35kb) text file in HDFS.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  content : string
+}
+
+create external  table TextDataset(LineType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/large_text"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="."));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.2.update.sqlpp
new file mode 100644
index 0000000..ab3c52e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a large (35kb) text file in HDFS.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.3.query.sqlpp
new file mode 100644
index 0000000..066dd06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_03/hdfs_03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a large (35kb) text file in HDFS.
+
+use test;
+
+
+select element {'word':tok,'count':test.count(token)}
+from  TextDataset as line,
+      tokens as token
+with  tokens as test."word-tokens"(line.content)
+group by token as tok
+order by tok
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.1.ddl.sqlpp
new file mode 100644
index 0000000..07d9acc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.1.ddl.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  content : string
+}
+
+create external  table TextDataset(LineType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/textFileS"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"="."),("local-socket-path"="/var/lib/hadoop-hdfs/dn_socket"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.2.update.sqlpp
new file mode 100644
index 0000000..7054391
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.3.query.sqlpp
new file mode 100644
index 0000000..7892d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
+use test;
+
+
+select element {'word':tok,'count':test.count(token)}
+from  TextDataset as line,
+      tokens as token
+with  tokens as test."word-tokens"(line.content)
+group by token as tok
+order by tok
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.1.ddl.sqlpp
new file mode 100644
index 0000000..0b5fe8e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.1.ddl.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a file in HDFS.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  line : string
+}
+
+create external  table TextDataset(LineType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/asterix_info.txt"),("input-format"="text-input-format"),("format"="delimited-text"),("delimiter"="."));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.2.update.sqlpp
new file mode 100644
index 0000000..df4b793
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a file in HDFS.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.3.query.sqlpp
new file mode 100644
index 0000000..5313e23
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a file in HDFS.
+
+use test;
+
+
+select element x
+from  TextDataset as x
+order by x.line
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.1.ddl.sqlpp
new file mode 100644
index 0000000..07bd38c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Create an  dataset and load it from two file splits
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLPadm(DBLPType) primary key id hints ("CARDINALITY"="200");
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.2.update.sqlpp
new file mode 100644
index 0000000..188926c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.2.update.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.
+ */
+/*
+* Description  : Create an  dataset and load it from two file splits 
+
+use test;
+
+
+load  table DBLPadm using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/part-00000.adm,nc1://data/dblp-small/part-00001.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.3.query.sqlpp
new file mode 100644
index 0000000..453305f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an  dataset and load it from two file splits 
+
+use test;
+
+
+select element paper
+from  DBLPadm as paper
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.1.ddl.sqlpp
new file mode 100644
index 0000000..ba890d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.1.ddl.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineType as
+ closed {
+  content : string
+}
+
+create external  table TextDataset(LineType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/textFileS"),("input-format"="sequence-input-format"),("format"="delimited-text"),("delimiter"=".")) hints ("CARDINALITY"="10");
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.2.update.sqlpp
new file mode 100644
index 0000000..7054391
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.3.query.sqlpp
new file mode 100644
index 0000000..7892d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains a tuples, the lines from a (*sequence*) file in HDFS.
+
+use test;
+
+
+select element {'word':tok,'count':test.count(token)}
+from  TextDataset as line,
+      tokens as token
+with  tokens as test."word-tokens"(line.content)
+group by token as tok
+order by tok
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.1.ddl.sqlpp
new file mode 100644
index 0000000..6856b54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.1.ddl.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.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+drop  database feeds if exists;
+create  database feeds;
+
+use feeds;
+
+
+create type feeds.TweetType as
+ closed {
+  id : string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}
+
+create  table Tweets(TweetType) primary key id hints ("CARDINALITY"="200");
+
+create  primary feed TweetFeed using file_feed (("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("type-name"="TweetType"),("tuple-interval"="10"));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.2.update.sqlpp
new file mode 100644
index 0000000..af5bb9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+set "wait-for-completion-feed" "true";
+
+connect  feed TweetFeed to  table Tweets using policy "BasicFT";
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.3.query.sqlpp
new file mode 100644
index 0000000..bc54e72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a feed dataset that uses the feed simulator adapter. 
+
+use feeds;
+
+
+select element x
+from  Tweets as x
+order by x.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.sqlpp
new file mode 100644
index 0000000..d1e2908
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Index Nested Loop Join on three datasets. Two index nested loop joins should be nested properly.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int32,
+  statuses_count : int32,
+  name : string,
+  followers_count : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : string,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "forward-from" : int64,
+  "retweet-from" : int64,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type test.ResultType as
+{
+  vertexid : int64,
+  rank : double
+}
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  table results(ResultType) primary key vertexid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.sqlpp
new file mode 100644
index 0000000..c9bf2d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.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.
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/index-join/tw_messages.adm"),("format"="adm"));
+
+load  table TwitterUsers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/index-join/tw_users.adm"),("format"="adm"));
+
+load  table results using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/index-join/results.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.sqlpp
new file mode 100644
index 0000000..bc6959d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element tm.tweetid
+from  TwitterUsers as tu,
+      TweetMessages as tm,
+      results as r
+where ((r.vertexid /*+ indexnl */  = tm.tweetid) and (tm.user /*+ indexnl */  = tu."screen-name"))
+order by tm.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ddl.sqlpp
new file mode 100644
index 0000000..f49d925
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Orders(OrderType) primary key oid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.2.update.sqlpp
new file mode 100644
index 0000000..5460ce4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.2.update.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.
+ */
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.3.query.sqlpp
new file mode 100644
index 0000000..955c173
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.3.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'cid':c.cid,'oid':o.oid}
+from  Customers as c,
+      Orders as o
+where (c.cid /*+ indexnl */  = o.cid)
+order by c.cid,o.oid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.1.ddl.sqlpp
new file mode 100644
index 0000000..e20f3a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.2.update.sqlpp
new file mode 100644
index 0000000..b97e22d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.3.ddl.sqlpp
new file mode 100644
index 0000000..d815a7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  DBLP has a secondary btree index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index authors_index  on DBLP (authors) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.4.query.sqlpp
new file mode 100644
index 0000000..376947d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.4.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  DBLP has a secondary btree index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bid':b.id,'authors':a.authors}
+from  DBLP as a,
+      CSX as b
+where (a.authors /*+ indexnl */  = b.authors)
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cf55ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.1.ddl.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  CSX has a secondary btree index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.2.update.sqlpp
new file mode 100644
index 0000000..c1754c4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.3.ddl.sqlpp
new file mode 100644
index 0000000..583abf2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  CSX has a secondary btree index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index authors_index  on CSX (authors) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.4.query.sqlpp
new file mode 100644
index 0000000..d4878b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.4.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  CSX has a secondary btree index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bid':b.id,'authors':a.authors}
+from  DBLP as a,
+      CSX as b
+where (a.authors /*+ indexnl */  = b.authors)
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.1.ddl.sqlpp
new file mode 100644
index 0000000..c58b9ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  Both datasets have a secondary btree index on authors. So, given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  (outer relation: the first relation described in the for-loop, inner relation: the other relation)
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.2.update.sqlpp
new file mode 100644
index 0000000..c560af9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.3.ddl.sqlpp
new file mode 100644
index 0000000..206a6cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.3.ddl.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  Both datasets have a secondary btree index on authors. So, given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  (outer relation: the first relation described in the for-loop, inner relation: the other relation)
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index CSX_authors_index  on CSX (authors) type btree;
+
+create  index DBLP_authors_index  on DBLP (authors) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.4.query.sqlpp
new file mode 100644
index 0000000..11820cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their authors.
+ *                  Both datasets have a secondary btree index on authors. So, given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  (outer relation: the first relation described in the for-loop, inner relation: the other relation)
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bid':b.id,'authors':a.authors}
+from  DBLP as a,
+      CSX as b
+where (a.authors /*+ indexnl */  = b.authors)
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
new file mode 100644
index 0000000..cc1a2ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData1(MyRecord) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
new file mode 100644
index 0000000..ac337aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.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.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table MyData1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyData2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
new file mode 100644
index 0000000..19e5310
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index rtree_index  on MyData1 (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp
new file mode 100644
index 0000000..7d0ad26
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.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.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bid':b.id,'apt':a.point,'bp':b.point}
+from  MyData1 as a,
+      MyData2 as b
+where (test."spatial-intersect"(a.point,b.point) and (a.id != b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..4454b2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..537e280
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..2f0dd73
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..4454b2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..537e280
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..d2b114f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..9f2f4c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgKeywordIx  on TweetMessages ("message-text") type keyword;
+
+create  index msgNgramIx  on TweetMessages ("message-text") type ngram (3);
+
+create  index topicKeywordIx  on TweetMessages ("referred-topics") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..537e280
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..661261f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use test;
+
+
+select element {'tweet':{'id':t1.tweetid,'topics':t1."referred-topics"},'similar-tweets':(
+        select element {'id':t2.tweetid,'topics':t2."referred-topics"}
+        from  TweetMessages as t2
+        with  sim as test."similarity-jaccard-check"(t1."referred-topics",t2."referred-topics",0.500000f)
+        where (sim[0] and (t2.tweetid != t1.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..9f2f4c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgKeywordIx  on TweetMessages ("message-text") type keyword;
+
+create  index msgNgramIx  on TweetMessages ("message-text") type ngram (3);
+
+create  index topicKeywordIx  on TweetMessages ("referred-topics") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..537e280
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..8ee9785
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use test;
+
+
+select element {'tweet':{'id':t1.tweetid,'topics':t1."message-text"},'similar-tweets':(
+        select element {'id':t2.tweetid,'topics':t2."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1."message-text",t2."message-text",7)
+        where (sim[0] and (t2.tweetid != t1.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..4c0c0f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..05f0740
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..ecf5895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..4c0c0f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (countB) type btree;
+
+create  index msgTextIx  on TweetMessages ("message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..05f0740
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..b88abe7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2."sender-location",n) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
new file mode 100644
index 0000000..ea7c83f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create  table employee(Emp) primary key id;
+
+create  index idx_employee_f_l_name  on employee (fname,lname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
new file mode 100644
index 0000000..e1103ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson" 
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+load  table employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.query.sqlpp
new file mode 100644
index 0000000..3976e04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson" 
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+select element l
+from  employee as l
+where ((l.fname > 'Julio') and (l.lname > 'Mattocks') and (l.fname <= 'Micco') and (l.lname < 'Vangieson'))
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
new file mode 100644
index 0000000..61f2a02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create  table employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
new file mode 100644
index 0000000..248b7f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+load  table employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp
new file mode 100644
index 0000000..437062e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.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;
+
+
+create  index idx_employee_f_l_name  on employee (fname,lname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp
new file mode 100644
index 0000000..2375180
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+select element l
+from  employee as l
+where ((l.fname = 'Julio') and (l.lname = 'Isa'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
new file mode 100644
index 0000000..0beaa09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.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.
+ */
+/*
+ * Description     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+{
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
new file mode 100644
index 0000000..7eac956
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp
new file mode 100644
index 0000000..6fd3b47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
new file mode 100644
index 0000000..307af1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey,'o_orderstatus':o.o_orderstatus,'o_orderkey2':o2.o_orderkey,'o_custkey2':o2.o_custkey,'o_orderstatus2':o2.o_orderstatus}
+from  Orders as o,
+      Orders as o2
+where ((o.o_custkey = 20) and (o2.o_custkey = 10) and (o.o_orderstatus < o2.o_orderstatus))
+order by o.o_orderkey,o2.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..31cffec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.update.sqlpp
new file mode 100644
index 0000000..c810510
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.update.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;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/tiny01/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..8934610
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ddl.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;
+
+
+create  index age_index  on Customers (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.query.sqlpp
new file mode 100644
index 0000000..c9d3009
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  Customers as c
+where (c.age < 20)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.ddl.sqlpp
new file mode 100644
index 0000000..6f72d2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : string,
+  idx : string,
+  "no-idx" : string
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (idx) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.2.update.sqlpp
new file mode 100644
index 0000000..92d3b17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.2.update.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.
+ */
+
+use test;
+
+
+insert into TestSet
+select element {'id':x,'idx':x,'no-idx':x}
+from  {{'one','two','three'}} as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.sqlpp
new file mode 100644
index 0000000..2120ebc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  TestSet as x
+where ((x.id = 'one') or (x.id = 'two') or (x.id = 'two'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..f1d7f46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
new file mode 100644
index 0000000..0ac4ba6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..f1d7f46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
new file mode 100644
index 0000000..3e7d24c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':paper.id,'title':paper.title}
+from  DBLP as paper
+where test."edit-distance-contains"(paper.title,'Multmedia',1)[0]
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp
new file mode 100644
index 0000000..1e7b847
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
new file mode 100644
index 0000000..381bad2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp
new file mode 100644
index 0000000..f1d7f46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
new file mode 100644
index 0000000..98db760
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'id':paper.id,'title':paper.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..1e7b847
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (authors) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..18e91b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..f1d7f46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..0cb9cf1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.sqlpp
new file mode 100644
index 0000000..9d759f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.update.sqlpp
new file mode 100644
index 0000000..534b6c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.update.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;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ddl.sqlpp
new file mode 100644
index 0000000..2f8c10f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ddl.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;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.query.sqlpp
new file mode 100644
index 0000000..9a8b989
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element c
+from  Customers as c
+with  ed as test."edit-distance-check"(c.interests,['computers','wine','walking'],3)
+where ed[0]
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..9d759f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..534b6c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.update.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;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..2f8c10f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ddl.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;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..396fb1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element c
+from  Customers as c
+with  ed as test."edit-distance-check"(c.interests,['computers','wine','walking'],1)
+where ed[0]
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..9d759f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..534b6c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.update.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;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..2f8c10f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ddl.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;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..aab149a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.interests,['databases','computers','wine'],0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..0e848c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..7402817
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.update.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;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..2f8c10f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ddl.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;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..1e8f182
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.interests,{{'computers','wine','databases'}},0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..c782c45
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.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;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
new file mode 100644
index 0000000..0ac4ba6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..c782c45
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.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;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..257e5d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ddl.sqlpp
new file mode 100644
index 0000000..f32d58f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+{
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.update.sqlpp
new file mode 100644
index 0000000..e803beb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.update.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 tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ddl.sqlpp
new file mode 100644
index 0000000..6fd3b47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.query.sqlpp
new file mode 100644
index 0000000..6bdc3fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
new file mode 100644
index 0000000..3094851
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp
new file mode 100644
index 0000000..e803beb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.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 tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp
new file mode 100644
index 0000000..6fd3b47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
new file mode 100644
index 0000000..6bdc3fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ddl.sqlpp
new file mode 100644
index 0000000..c2a5bc4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+{
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.update.sqlpp
new file mode 100644
index 0000000..e803beb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.update.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 tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ddl.sqlpp
new file mode 100644
index 0000000..6fd3b47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.query.sqlpp
new file mode 100644
index 0000000..56586cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where (o.o_custkey = 40)
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
new file mode 100644
index 0000000..3094851
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp
new file mode 100644
index 0000000..e803beb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.2.update.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 tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp
new file mode 100644
index 0000000..6fd3b47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
new file mode 100644
index 0000000..56586cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  Orders as o
+where (o.o_custkey = 40)
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.1.ddl.sqlpp
new file mode 100644
index 0000000..61d7ca9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+{
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.3.ddl.sqlpp
new file mode 100644
index 0000000..7094320
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.3.ddl.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;
+
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.4.query.sqlpp
new file mode 100644
index 0000000..558a03b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search-open/range-search-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where ((c.l_suppkey < 100) and (c.l_suppkey > 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.1.ddl.sqlpp
new file mode 100644
index 0000000..4cf856b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.2.update.sqlpp
new file mode 100644
index 0000000..d0d7538
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.2.update.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;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.3.ddl.sqlpp
new file mode 100644
index 0000000..7094320
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.3.ddl.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;
+
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.4.query.sqlpp
new file mode 100644
index 0000000..558a03b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/range-search/range-search.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItem as c
+where ((c.l_suppkey < 100) and (c.l_suppkey > 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ddl.sqlpp
new file mode 100644
index 0000000..52704f2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.update.sqlpp
new file mode 100644
index 0000000..c5b67c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.update.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;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ddl.sqlpp
new file mode 100644
index 0000000..662b250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.query.sqlpp
new file mode 100644
index 0000000..ecebddb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-circle"(test."create-point"(5.0,5.0),0.5))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..977439c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point?,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..707ff95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.update.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;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..662b250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.query.sqlpp
new file mode 100644
index 0000000..8426681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..33b2d45e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..c5b67c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.update.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;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..662b250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.query.sqlpp
new file mode 100644
index 0000000..8426681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..52704f2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..c5b67c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.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;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..662b250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
new file mode 100644
index 0000000..8426681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..58c3592
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..3b6ff4b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..a12d580
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (name) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..f8fb1e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'a':a.name,'b':b.name,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.name,b.name)
+where ((ed <= 4) and (a.cid < b.cid))
+order by ed,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..58ae67c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..4235354
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..b5a4ef4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (name) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..56dade3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'a':a.name,'b':b.name}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.name,b.name) <= 4) and (a.cid < b.cid))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..7bdf5ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..44a7388
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..e210d47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..7cba749
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.title,'b':b.title,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+order by jacc,a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..03ec203
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..7228f36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..d879f06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..22cd37c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.title,'b':b.title}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..48bbebe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..63817f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..fef7f30
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..aea4983
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.interests,'b':b.interests,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.interests,b.interests)
+where ((test.len(a.interests) > 2) and (test.len(b.interests) > 2) and (ed <= 1) and (a.cid < b.cid))
+order by ed,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..85e8564
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..a179da8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..ec5ba63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..3047264
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.interests,'b':b.interests}
+from  Customers as a,
+      Customers2 as b
+where ((test.len(a.interests) > 2) and (test.len(b.interests) > 2) and (test."edit-distance"(a.interests,b.interests) <= 1) and (a.cid < b.cid))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..db0e7cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..ef6de8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..b322d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..a3a1567
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.interests,'b':b.interests,'jacc':jacc}
+from  Customers as a,
+      Customers2 as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by jacc,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..24b6212
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..65b2810
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..9522da1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..00295ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.interests,'b':b.interests}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..a9eb494
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..681cbfc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..77b78db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..b69d973
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.interests,'b':b.interests,'jacc':jacc}
+from  Customers as a,
+      Customers2 as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by jacc,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..f53e6dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int32?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..9dc6553
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..e2b38d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..3e0a10d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.interests,'b':b.interests}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..af179d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..75912df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..2dd0e60
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..425617f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.title,'b':b.title,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+order by jacc,a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..c57c4d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..73a54c4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..90ef8fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..4f17bc7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'a':a.title,'b':b.title}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..176e0f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..6b514cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..a8a5937
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (name) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..060a78f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.name,b.name)
+where ((ed <= 4) and (a.cid < b.cid))
+order by ed,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..c87895a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..59c3476
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..e273f85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (name) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..72f2c3b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.name,b.name) <= 4) and (a.cid < b.cid))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..cd26590
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..f5d705b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..8ebf00d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..0481499
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+order by jacc,a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..9054a0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..72af9cb6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..a87b5fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..9cc39c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..1251bb5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..dcbbc6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..12a2bd3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..1949fe9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.interests,b.interests)
+where ((test.len(a.interests) > 2) and (test.len(b.interests) > 2) and (ed <= 1) and (a.cid < b.cid))
+order by ed,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..ef82d8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..3a9d692
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..300b793
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..2347485
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((test.len(a.interests) > 2) and (test.len(b.interests) > 2) and (test."edit-distance"(a.interests,b.interests) <= 1) and (a.cid < b.cid))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..3511a5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..6d0da7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..26a3ebe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..cd86850
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'a':a,'b':b,'jacc':jacc}
+from  Customers as a,
+      Customers2 as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by jacc,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..99f182e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..58307c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..81c1b67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..171d15b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest lists.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'a':a,'b':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..74c204b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..936f145
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..698345d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..b4d93f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'a':a,'b':b,'jacc':jacc}
+from  Customers as a,
+      Customers2 as b
+with  jacc as  /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests)
+where ((jacc >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by jacc,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..ecf7a2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..4e1367e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..8a89199
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index interests_index  on Customers (interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..924cfcd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
+ *                  Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'a':a,'b':b}
+from  Customers as a,
+      Customers2 as b
+where (( /*+ indexnl */ test."similarity-jaccard"(a.interests,b.interests) >= 0.900000f) and (a.cid < b.cid) and (test.len(a.interests) > 1) and (test.len(b.interests) > 1))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..8bbde7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..bab565f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..33236a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..abf7994
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+order by jacc,a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..cf2316a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.1.ddl.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..a9c30f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..9dce3a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..e0a4c72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/inverted-index-join/word-jaccard/word-jaccard.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/json/int01/int01.1.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/json/int01/int01.1.query.sqlpp
new file mode 100644
index 0000000..14cff19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/json/int01/int01.1.query.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.
+ */
+
+select element [1,2];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.1.ddl.sqlpp
new file mode 100644
index 0000000..9dafb3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.1.ddl.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.
+ */
+/*
+ * Description    : Left-outer joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.2.update.sqlpp
new file mode 100644
index 0000000..d49816f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.3.query.sqlpp
new file mode 100644
index 0000000..bdd287e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.3.query.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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    : Left-outer joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *
+ *					TODO(@Sattam): given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *					
+ *					regression test 2 for issue 285--having an order by and limit for the outer loop relation
+ *
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bids':(
+        select element b.id
+        from  CSX as b
+        where (a.authors = b.authors)
+        order by b.id
+    )}
+from  DBLP as a
+order by a.id
+limit 10
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.1.ddl.sqlpp
new file mode 100644
index 0000000..763a133
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.1.ddl.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.
+ */
+/*
+ * Description    : Left-outer joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title.
+ *
+ *                  TODO(@Sattam): given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *
+ *                  regression test for issue 285
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.2.update.sqlpp
new file mode 100644
index 0000000..d49816f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.3.query.sqlpp
new file mode 100644
index 0000000..0b5a434
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue285/query_issue285.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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    : Left-outer joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *
+ *					TODO(@Sattam): given the 'indexnl' hint 
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *					
+ *					regression test for issue 285--having an order by for the outer loop relation
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bids':(
+        select element b.id
+        from  CSX as b
+        where (a.authors = b.authors)
+        order by b.id
+    )}
+from  DBLP as a
+order by a.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.1.ddl.sqlpp
new file mode 100644
index 0000000..f809bff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Left-outer joins two datasets, DBLP and CSX, based on their authors and titles.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.2.update.sqlpp
new file mode 100644
index 0000000..0103186
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.3.query.sqlpp
new file mode 100644
index 0000000..56733d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue658/query_issue658.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Left-outer joins two datasets, DBLP and CSX, based on their authors and titles.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bids':(
+        select element b.id
+        from  CSX as b
+        where ((a.authors = b.authors) and (a.title != b.title))
+        order by b.id
+    )}
+from  DBLP as a
+order by a.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.1.ddl.sqlpp
new file mode 100644
index 0000000..c3b96af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.sType as
+ closed {
+  b : int64
+}
+
+create  table s(sType) primary key b;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.2.update.sqlpp
new file mode 100644
index 0000000..b1e12c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+use test;
+
+
+insert into s
+select element {'b':1};
+insert into s
+select element {'b':3};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.3.query.sqlpp
new file mode 100644
index 0000000..2815c7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+use test;
+
+
+select element {'x':x,'y':y}
+from  s as x,
+      (
+    select element z.c
+    from  {{{'a':1,'c':1},{'a':2,'c':2},{'a':1,'c':null}}} as z
+    where (x.b = z.a)
+) as y
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.1.ddl.sqlpp
new file mode 100644
index 0000000..c3b96af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.sType as
+ closed {
+  b : int64
+}
+
+create  table s(sType) primary key b;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.2.update.sqlpp
new file mode 100644
index 0000000..b1e12c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+use test;
+
+
+insert into s
+select element {'b':1};
+insert into s
+select element {'b':3};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.3.query.sqlpp
new file mode 100644
index 0000000..7465314
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/leftouterjoin/query_issue849/query_issue849.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=849
+ * Expected Res : SUCCESS
+ * Date         : 2nd Feb. 2015
+ */
+
+use test;
+
+
+select element {'x':x,'y':y}
+from  {{{'a':1},{'a':2}}} as x,
+      (
+    select element z.b
+    from  s as z
+    where (x.a = z.b)
+) as y
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.3.query.sqlpp
new file mode 100644
index 0000000..208a440
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/any-collection-member_01/any-collection-member_01.3.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;
+
+
+{{1,1,1}}[?];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.3.query.sqlpp
new file mode 100644
index 0000000..5deed96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_01/get-item_01.3.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;
+
+
+[1,2,3,4][2];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.3.query.sqlpp
new file mode 100644
index 0000000..817c408
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/get-item_02/get-item_02.3.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;
+
+
+[1,2,3,4][(2 + 1)];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.3.query.sqlpp
new file mode 100644
index 0000000..d84d391
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_01/len_01.3.query.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 element [test.len([]),test.len([1]),test.len([1,2]),test.len([1,2,3]),test.len({{}}),test.len({{1}}),test.len({{1,2}}),test.len({{1,2,3}})]
+from  [1] as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.3.query.sqlpp
new file mode 100644
index 0000000..027d7db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/len_null_01/len_null_01.3.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;
+
+
+{'len1':test.len([]),'len2':null};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.3.query.sqlpp
new file mode 100644
index 0000000..fe54bab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_01/listify_01.3.query.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 element token
+from  [1,2,3] as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.3.query.sqlpp
new file mode 100644
index 0000000..31b5eaf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_02/listify_02.3.query.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 element token
+from  ['foo','bar'] as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.1.ddl.sqlpp
new file mode 100644
index 0000000..d92dec7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :  Test that a listify on a nullable type creates a homogeneous list of type ANY.
+ *                     Guards against regression to issue 186.
+ * Expected Result  :  Success
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.2.update.sqlpp
new file mode 100644
index 0000000..2f8160a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.2.update.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.
+ */
+/*
+ * Description      :  Test that a listify on a nullable type creates a homogeneous list of type ANY.
+ *                     Guards against regression to issue 186.
+ * Expected Result  :  Success
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.3.query.sqlpp
new file mode 100644
index 0000000..8f6444e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/listify_03/listify_03.3.query.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.
+ */
+/*
+ * Description      :  Test that a listify on a nullable type creates a homogeneous list of type ANY.
+ *                     Guards against regression to issue 186.
+ * Expected Result  :  Success
+ */
+
+use test;
+
+
+select element test.min(y)
+from  [1,2] as x
+with  y as (
+      select element test.min(i)
+      from  [[1,2,3],[10,20,30],[-2,-5,0]] as i
+  )
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.3.query.sqlpp
new file mode 100644
index 0000000..bd7d014
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.3.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;
+
+
+select element ['foo','bar','foobar'];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.3.query.sqlpp
new file mode 100644
index 0000000..649c7be
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.3.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;
+
+
+select element [['foo','bar'],['foobar']];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.3.query.sqlpp
new file mode 100644
index 0000000..45f6f9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.3.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;
+
+
+select element [null,null,null];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.3.query.sqlpp
new file mode 100644
index 0000000..341d40f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/ordered-list-constructor_04/ordered-list-constructor_04.3.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;
+
+
+select element [[1,'two',null],[]];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.3.query.sqlpp
new file mode 100644
index 0000000..1d3925d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/query-issue428/query-issue428.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue400
+
+select element some a1 in a,
+b1 in b satisfies (a1 < b1)
+from  [[1,2],[3,4,5]] as a,
+      [[6,7],[8,9,10]] as b
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.3.query.sqlpp
new file mode 100644
index 0000000..c5496c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/scan-collection_01/scan-collection_01.3.query.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 element u
+from  [1,2,3] as u
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.3.query.sqlpp
new file mode 100644
index 0000000..89fb4f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_01/union_01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element x
+from  {{1,3}}
+    union
+    {{1,2}} as x
+order by x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.3.query.sqlpp
new file mode 100644
index 0000000..25a54ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/union_02/union_02.3.query.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.
+ */
+
+use test;
+
+
+select element z
+from  (
+    select element x
+    from  {{3,2}} as x
+)
+    union
+    (
+    select element y
+    from  {{2,1}} as y
+) as z
+order by z
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.3.query.sqlpp
new file mode 100644
index 0000000..426ced1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.3.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;
+
+
+select element {{'foo','bar','foobar'}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.3.query.sqlpp
new file mode 100644
index 0000000..dc7f86c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.3.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;
+
+
+select element {{{{'foo'}},{{'bar','foobar'}}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.3.query.sqlpp
new file mode 100644
index 0000000..4867d6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.3.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;
+
+
+select element {{null,null,null}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.3.query.sqlpp
new file mode 100644
index 0000000..c61a813
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/list/unordered-list-constructor_04/unordered-list-constructor_04.3.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;
+
+
+select element {{{{1,'two',null}},{{}}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_bianry.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_bianry.1.ddl.sqlpp
new file mode 100644
index 0000000..59b57f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_bianry.1.ddl.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.
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+{
+  ba : binary
+}
+
+create  table testds(test) primary key ba;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_binary.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_binary.2.update.sqlpp
new file mode 100644
index 0000000..a4f258f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_binary.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/adm-load/binary_type.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_binary.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_binary.3.query.sqlpp
new file mode 100644
index 0000000..fd3e1e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/adm_binary/adm_binary.3.query.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 temp;
+
+
+select element i
+from  testds as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.1.ddl.sqlpp
new file mode 100644
index 0000000..667388e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float?,
+  double : double?,
+  date : string?,
+  time : string?,
+  datetime : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.2.update.sqlpp
new file mode 100644
index 0000000..02da753
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_01.csv"),("format"="delimited-text"),("delimiter"=","));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.3.query.sqlpp
new file mode 100644
index 0000000..65d4d3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_01/csv_01.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'double':i.double,'date-before':i.date,'date-after':temp.date(i.date),'time-before':i.time,'time-after':temp.time(i.time),'datetime-before':i.datetime,'datetime-after':temp.datetime(i.datetime)}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.1.ddl.sqlpp
new file mode 100644
index 0000000..00f96c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float?,
+  double : double?,
+  date : string,
+  time : string,
+  datetime : string
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.2.update.sqlpp
new file mode 100644
index 0000000..02da753
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_01.csv"),("format"="delimited-text"),("delimiter"=","));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.3.query.sqlpp
new file mode 100644
index 0000000..aed1627
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_02/csv_02.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'double':i.double,'date-string':i.date,'time-string':i.time,'datetime-string':i.datetime}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.1.ddl.sqlpp
new file mode 100644
index 0000000..3eb61e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float,
+  floatq : float?,
+  double : double,
+  doubleq : double?,
+  string : string,
+  stringq : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.2.update.sqlpp
new file mode 100644
index 0000000..9369aad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_02.csv"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.3.query.sqlpp
new file mode 100644
index 0000000..d392d9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_03/csv_03.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'floatq':i.floatq,'double':i.double,'doubleq':i.doubleq,'string':i.string,'stringq':i.stringq}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.1.ddl.sqlpp
new file mode 100644
index 0000000..e0e5e40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ * In this test, we check quote
+ * and delimiter in a field
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float,
+  stringa : string,
+  stringb : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.2.update.sqlpp
new file mode 100644
index 0000000..6291c2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_03.csv"),("format"="delimited-text"),("delimiter"=","),("quote"="\""));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.3.query.sqlpp
new file mode 100644
index 0000000..dd2443c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_04/csv_04.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'stringa':i.stringa,'stringb':i.stringb}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.1.ddl.sqlpp
new file mode 100644
index 0000000..935418d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a field is not enclosed in two quotes properly. It misses one quote.
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int32,
+  float : float,
+  stringa : string,
+  stringb : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.2.update.sqlpp
new file mode 100644
index 0000000..68d60e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a field is not enclosed in two quotes properly. It misses one quote.
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_04_quote_error.csv"),("format"="delimited-text"),("delimiter"=","),("quote"="\""));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.3.query.sqlpp
new file mode 100644
index 0000000..16bfca5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_05/csv_05.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a field is not enclosed in two quotes properly. It misses one quote.
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'stringa':i.stringa,'stringb':i.stringb}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.1.ddl.sqlpp
new file mode 100644
index 0000000..50163a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a whitespace is placed after the delimiter, and there is a quote after that.
+ * According to RFC (http://tools.ietf.org/html/rfc4180), this is not allowed.
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int32,
+  float : float,
+  stringa : string,
+  stringb : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.2.update.sqlpp
new file mode 100644
index 0000000..e349f80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a whitespace is placed after the delimiter, and there is a quote after that.
+ * According to RFC (http://tools.ietf.org/html/rfc4180), this is not allowed.
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_05_space_error_1.csv"),("format"="delimited-text"),("delimiter"=","),("quote"="\""));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.3.query.sqlpp
new file mode 100644
index 0000000..2f20363
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_06/csv_06.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a whitespace is placed after the delimiter, and there is a quote after that.
+ * According to RFC (http://tools.ietf.org/html/rfc4180), this is not allowed.
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'stringa':i.stringa,'stringb':i.stringb}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.1.ddl.sqlpp
new file mode 100644
index 0000000..111e646
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: fail - a whitespace is placed after a quote, and there is a delimiter after that space.
+ * According to RFC (http://tools.ietf.org/html/rfc4180), this is not allowed.
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int32,
+  float : float,
+  stringa : string,
+  stringb : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.2.update.sqlpp
new file mode 100644
index 0000000..42f2b6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_06_space_error_2.csv"),("format"="delimited-text"),("delimiter"=","),("quote"="\""));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.3.query.sqlpp
new file mode 100644
index 0000000..dd2443c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_07/csv_07.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'stringa':i.stringa,'stringb':i.stringb}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.1.ddl.sqlpp
new file mode 100644
index 0000000..667388e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float?,
+  double : double?,
+  date : string?,
+  time : string?,
+  datetime : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.2.update.sqlpp
new file mode 100644
index 0000000..718e466
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_08_header.csv.cr"),("format"="delimited-text"),("header"="true"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.3.query.sqlpp
new file mode 100644
index 0000000..65d4d3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_cr/csv_08.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'double':i.double,'date-before':i.date,'date-after':temp.date(i.date),'time-before':i.time,'time-after':temp.time(i.time),'datetime-before':i.datetime,'datetime-after':temp.datetime(i.datetime)}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.1.ddl.sqlpp
new file mode 100644
index 0000000..667388e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float?,
+  double : double?,
+  date : string?,
+  time : string?,
+  datetime : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.2.update.sqlpp
new file mode 100644
index 0000000..90c0411
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_08_header.csv.crlf"),("format"="delimited-text"),("header"="true"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.3.query.sqlpp
new file mode 100644
index 0000000..65d4d3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_crlf/csv_08.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'double':i.double,'date-before':i.date,'date-after':temp.date(i.date),'time-before':i.time,'time-after':temp.time(i.time),'datetime-before':i.datetime,'datetime-after':temp.datetime(i.datetime)}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.1.ddl.sqlpp
new file mode 100644
index 0000000..667388e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+drop  database temp if exists;
+create  database temp;
+
+use temp;
+
+
+create type temp.test as
+ closed {
+  id : int64,
+  float : float?,
+  double : double?,
+  date : string?,
+  time : string?,
+  datetime : string?
+}
+
+create  table testds(test) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.2.update.sqlpp
new file mode 100644
index 0000000..6b71347
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.2.update.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+load  table testds using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/csv/sample_08_header.csv.lf"),("format"="delimited-text"),("header"="true"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.3.query.sqlpp
new file mode 100644
index 0000000..65d4d3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/csv_08_header_lf/csv_08.3.query.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.
+ */
+/**
+ *
+ * CSV file loading test
+ * Expected result: success
+ *
+ */
+
+use temp;
+
+
+select element {'id':i.id,'float':i.float,'double':i.double,'date-before':i.date,'date-after':temp.date(i.date),'time-before':i.time,'time-after':temp.time(i.time),'datetime-before':i.datetime,'datetime-after':temp.datetime(i.datetime)}
+from  testds as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/duplicate-key-error/duplicate-key-error.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/duplicate-key-error/duplicate-key-error.1.ddl.sqlpp
new file mode 100644
index 0000000..bb2ae81
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/duplicate-key-error/duplicate-key-error.1.ddl.sqlpp
@@ -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  : Create and load a dataset that has duplicate keys.
+ * Expected Res : Failure
+ * Date         : 04 July 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32
+}
+
+create  table mydataset(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/duplicate-key-error/duplicate-key-error.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/duplicate-key-error/duplicate-key-error.2.update.sqlpp
new file mode 100644
index 0000000..0bc93d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/duplicate-key-error/duplicate-key-error.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create and load a dataset that has duplicate keys.
+ * Expected Res : Failure
+ * Date         : 04 July 2013
+ */
+
+use test;
+
+
+load  table mydataset using "localfs" (("path"="nc1://data/duplicateKeys.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes-err-1/escapes-err-1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes-err-1/escapes-err-1.1.ddl.sqlpp
new file mode 100644
index 0000000..2b68429
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes-err-1/escapes-err-1.1.ddl.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.
+ */
+
+drop  database TestDataverse if exists;
+create  database TestDataverse;
+
+use TestDataverse;
+
+
+create type TestDataverse.TestType as
+{
+  id : string
+}
+
+create  table TestSet(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes-err-1/escapes-err-1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes-err-1/escapes-err-1.2.update.sqlpp
new file mode 100644
index 0000000..3d26b4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes-err-1/escapes-err-1.2.update.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 TestDataverse;
+
+
+load  table TestSet using "localfs" (("path"="nc1://data/escapes-err-1.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.1.ddl.sqlpp
new file mode 100644
index 0000000..2b68429
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.1.ddl.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.
+ */
+
+drop  database TestDataverse if exists;
+create  database TestDataverse;
+
+use TestDataverse;
+
+
+create type TestDataverse.TestType as
+{
+  id : string
+}
+
+create  table TestSet(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.2.update.sqlpp
new file mode 100644
index 0000000..b4cf73c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.2.update.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 TestDataverse;
+
+
+load  table TestSet using "localfs" (("path"="nc1://data/escapes01.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.3.query.sqlpp
new file mode 100644
index 0000000..253bee0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes01/escapes01.3.query.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.
+ */
+
+use TestDataverse;
+
+
+select element i
+from  TestSet as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.1.ddl.sqlpp
new file mode 100644
index 0000000..2b68429
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.1.ddl.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.
+ */
+
+drop  database TestDataverse if exists;
+create  database TestDataverse;
+
+use TestDataverse;
+
+
+create type TestDataverse.TestType as
+{
+  id : string
+}
+
+create  table TestSet(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.2.update.sqlpp
new file mode 100644
index 0000000..a188638
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.2.update.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 TestDataverse;
+
+
+load  table TestSet using "localfs" (("path"="nc1://data/escapes02.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.3.query.sqlpp
new file mode 100644
index 0000000..253bee0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/escapes02/escapes02.3.query.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.
+ */
+
+use TestDataverse;
+
+
+select element i
+from  TestSet as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.1.ddl.sqlpp
new file mode 100644
index 0000000..44357fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.1.ddl.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.
+ */
+/*
+ * Description  : Create and load a dataset but with an unspecified data format.
+ * Expected Res : Failure
+ * Date         : 16 Jan 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32,
+  age : int32,
+  name : string
+}
+
+create  table onektup(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.2.update.sqlpp
new file mode 100644
index 0000000..8b3d3e7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create and load a dataset but with an unspecified data format.
+ * Expected Res : Failure
+ * Date         : 16 Jan 2012
+ */
+
+use test;
+
+
+load  table onektup using "localfs" (("path"="nc1:///tmp/one.adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.3.query.sqlpp
new file mode 100644
index 0000000..5fa9a43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue14_query/issue14_query.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create and load a dataset but with an unspecified data format.
+ * Expected Res : Failure
+ * Date         : 16 Jan 2012
+ */
+
+use test;
+
+
+select element l
+from  onektup as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.1.ddl.sqlpp
new file mode 100644
index 0000000..24b5891
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.1.ddl.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.
+ */
+/*
+ * Description  : Load dataset with float numbers containing "E-4f"
+ * Expected Res : Success
+ * Date         : 01 Apr 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create  table Customers(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.2.update.sqlpp
new file mode 100644
index 0000000..035d6ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Load dataset with float numbers containing "E-4f"
+ * Expected Res : Success
+ * Date         : 01 Apr 2013
+ */
+
+use test;
+
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/customer-tiny-neg.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.3.query.sqlpp
new file mode 100644
index 0000000..50b4066
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue289_query/issue289_query.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Load dataset with float numbers containing "E-4f"
+ * Expected Res : Success
+ * Date         : 01 Apr 2013
+ */
+
+use test;
+
+
+select element test.count((
+    select element l
+    from  Customers as l
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue315_query/issue315_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue315_query/issue315_query.1.ddl.sqlpp
new file mode 100644
index 0000000..5274a68
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue315_query/issue315_query.1.ddl.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.
+ */
+/*
+ * Description  : Create and load a dataset but provide an invalid path argument with a missing ':'
+ * Expected Res : Failure
+ * Date         : 5 Apr 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32,
+  age : int32,
+  name : string
+}
+
+create  table onektup(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue315_query/issue315_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue315_query/issue315_query.2.update.sqlpp
new file mode 100644
index 0000000..4ee7ec8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue315_query/issue315_query.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create and load a dataset but provide an invalid path with a missing ':'
+ * Expected Res : Failure
+ * Date         : 5 Apr 2013
+ */
+
+use test;
+
+
+load  table onektup using "localfs" (("path"="nc1///tmp/one.adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ddl.sqlpp
new file mode 100644
index 0000000..d52ea1d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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  : Load dataset with two consecutive end_record token and correctly recognize them.
+ * Expected Res : Success
+ * Date         : 30 Oct 2013
+ */
+
+drop  database foo if exists;
+create  database foo;
+
+use foo;
+
+
+create type foo.bartype as
+{
+  id : int32,
+  nest_rec : {
+      id : int32
+  }
+
+}
+
+create  table baz(bartype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.2.update.sqlpp
new file mode 100644
index 0000000..32cf3ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Load dataset with two consecutive end_record token and correctly recognize them.
+ * Expected Res : Success
+ * Date         : 30 Oct 2013
+ */
+
+use foo;
+
+
+load  table baz using "localfs" (("path"="nc1://data/adm-load/double_end_record_token.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue650_query/issue650_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue650_query/issue650_query.1.ddl.sqlpp
new file mode 100644
index 0000000..63b2fee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue650_query/issue650_query.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Drop and recreate the dataverse between creating and loading a dataset.
+ * Expected Res : Failure
+ * Date         : 17 Oct 2013
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+create type fuzzyjoin.UserType as
+{
+  uid : int32,
+  name : string,
+  lottery_numbers : [int32],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue650_query/issue650_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue650_query/issue650_query.2.update.sqlpp
new file mode 100644
index 0000000..4d50371
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/issue650_query/issue650_query.2.update.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.
+ */
+/*
+ * Description  : Drop and recreate the dataverse between creating and loading a dataset.
+ * Expected Res : Failure
+ * Date         : 17 Oct 2013
+ */
+
+drop  database fuzzyjoin if exists;
+create  database fuzzyjoin;
+
+use fuzzyjoin;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.1.ddl.sqlpp
new file mode 100644
index 0000000..ec2c787
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 TestDataverse if exists;
+create  database TestDataverse;
+
+use TestDataverse;
+
+
+create type TestDataverse.TestType as
+{
+  id : int64,
+  int8 : int8,
+  int16 : int16,
+  int32 : int32,
+  int64 : int64,
+  float : float,
+  double : double,
+  int8_u : {{int8}}?,
+  int8_o : [int8]?,
+  int16_u : {{int16}}?,
+  int16_o : [int16]?,
+  int32_u : {{int32}}?,
+  int32_o : [int32]?,
+  int64_u : {{int64}}?,
+  int64_o : [int64]?,
+  float_u : {{float}}?,
+  float_o : [float]?,
+  double_u : {{double}}?,
+  double_o : [double]?
+}
+
+create  table TestSet(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.2.update.sqlpp
new file mode 100644
index 0000000..025493a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.2.update.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 TestDataverse;
+
+
+load  table TestSet using "localfs" (("path"="nc1://data/type_promotion.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.3.query.sqlpp
new file mode 100644
index 0000000..253bee0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/load/type_promotion_0/type_promotion_0.3.query.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.
+ */
+
+use TestDataverse;
+
+
+select element i
+from  TestSet as i
+order by i.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.1.ddl.sqlpp
new file mode 100644
index 0000000..b0f5265
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.2.update.sqlpp
new file mode 100644
index 0000000..699f515
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.2.update.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 TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.3.query.sqlpp
new file mode 100644
index 0000000..390f6c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/materialization/assign-reuse/assign-reuse.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 TinySocial;
+
+
+with  lonelyusers as (
+      select element d
+      from  FacebookUsers as d
+      where (TinySocial.count(d."friend-ids") < 2)
+  ),
+      lonelyusers2 as (
+      select element d
+      from  FacebookUsers as d
+      where (TinySocial.count(d."friend-ids") < 2)
+  )
+select element {'user1':{'id':l1.id,'name':l1.name},'user2':{'id':l2.id,'name':l2.name}}
+from  lonelyusers as l1,
+      lonelyusers2 as l2
+where (l1.id < l2.id)
+order by l1.id,l2.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.3.query.sqlpp
new file mode 100644
index 0000000..06bf1c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/float_01/float_01.3.query.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 element f
+from  [1.000000f,1.000000f,1.100000f,1.100000f,0.100000f,0.100000f] as f
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.1.ddl.sqlpp
new file mode 100644
index 0000000..9e85494
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 DMLTest if exists;
+create  database DMLTest;
+
+use DMLTest;
+
+
+create type DMLTest.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type DMLTest.FacebookUserType as
+ closed {
+  id : int64,
+  "id-copy" : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers1(FacebookUserType) primary key id;
+
+create  table FacebookUsers2(FacebookUserType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.2.update.sqlpp
new file mode 100644
index 0000000..12615e6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.2.update.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 DMLTest;
+
+
+load  table FacebookUsers1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/fbu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.3.update.sqlpp
new file mode 100644
index 0000000..4c82972
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.3.update.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.
+ */
+
+use DMLTest;
+
+
+insert into FacebookUsers2
+select element t
+from  FacebookUsers1 as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.4.query.sqlpp
new file mode 100644
index 0000000..21bf175
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/flushtest/flushtest.4.query.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 DMLTest;
+
+
+select element t
+from  FacebookUsers2 as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.1.ddl.sqlpp
new file mode 100644
index 0000000..bee7eaf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 twitter if exists;
+create  database twitter;
+
+use twitter;
+
+
+create type twitter.Tweet as
+{
+  id : int64,
+  tweetid : int64,
+  loc : point,
+  time : datetime,
+  text : string
+}
+
+create external  table TwitterData(Tweet) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.3.query.sqlpp
new file mode 100644
index 0000000..9a10d27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use twitter;
+
+
+select element {'word':tok,'count':twitter.count(token)}
+from  TwitterData as t,
+      tokens as token
+with  tokens as twitter."word-tokens"(t.text)
+group by token as tok
+order by twitter.count(token) desc,tok
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.3.query.sqlpp
new file mode 100644
index 0000000..609ec27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/ifthenelse_01/ifthenelse_01.3.query.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 element if ((2 > 1))
+    then 20
+    else 10;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.3.query.sqlpp
new file mode 100644
index 0000000..3f0e544
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/is-null_01/is-null_01.3.query.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;
+
+
+set "import-private-functions" "true";
+
+select element [test."is-null"(null),test."is-null"(10)];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.1.ddl.sqlpp
new file mode 100644
index 0000000..5c9e59a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.UserType as
+{
+  uid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create type test.VisitorType as
+{
+  vid : int64,
+  name : string,
+  lottery_numbers : [int64],
+  interests : {{string}}
+}
+
+create  table Users(UserType) primary key uid;
+
+create  table Visitors(VisitorType) primary key vid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.2.update.sqlpp
new file mode 100644
index 0000000..4efc411
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.2.update.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.
+ */
+
+use test;
+
+
+load  table Users using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/users.json"),("format"="adm"));
+
+load  table Visitors using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/users-visitors-small/visitors.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.3.query.sqlpp
new file mode 100644
index 0000000..5c32333
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'user':user,'visitor':visitor,'user-lottery_numbers-len':test.len(user.lottery_numbers),'visitor-lottery_numbers-len':test.len(visitor.lottery_numbers)}
+from  Users as user,
+      Visitors as visitor
+where (test.len(user.lottery_numbers) = test.len(visitor.lottery_numbers))
+order by user.uid,visitor.vid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.1.ddl.sqlpp
new file mode 100644
index 0000000..9020043
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.1.ddl.sqlpp
@@ -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    : Tries to partition a dataset by a non-existent field
+ * Expected Result: An error reporting that this is not allowed
+ * Author: zheilbron
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name1 : string
+}
+
+create  table testds(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.2.update.sqlpp
new file mode 100644
index 0000000..15aeb8d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tries to partition a dataset by a non-existent field
+ * Expected Result: An error reporting that this is not allowed
+ * Author: zheilbron
+ */
+
+use test;
+
+
+insert into testds
+select element {'name1':'John','name2':'Smith'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.3.query.sqlpp
new file mode 100644
index 0000000..25304c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tries to partition a dataset by a non-existent field
+ * Expected Result: An error reporting that this is not allowed
+ * Author: zheilbron
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.1.ddl.sqlpp
new file mode 100644
index 0000000..154c2bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for a
+ *                prefix search issue reported by Abdullah.
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.2.update.sqlpp
new file mode 100644
index 0000000..d53442b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for a
+ *                prefix search issue reported by Abdullah.
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.3.query.sqlpp
new file mode 100644
index 0000000..6837e2d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/prefix-search/prefix-search.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for a
+ *                prefix search issue reported by Abdullah.
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+use tpch;
+
+
+select element {'l_linenumber':l.l_linenumber,'l_l_orderkey':l.l_orderkey}
+from  LineItem as l
+where ((l.l_orderkey >= 0) and (l.l_orderkey < 100))
+order by l.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.1.ddl.sqlpp
new file mode 100644
index 0000000..49f1009
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.1.ddl.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.
+ */
+/*
+ * Description    : Joins two datasets after applying some functions to their name attributes.
+ *                  We expect the join to be transformed into a hybrid-hash join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table t1(TestType) primary key name;
+
+create  table t2(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.2.update.sqlpp
new file mode 100644
index 0000000..410e074
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.2.update.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.
+ */
+/*
+ * Description    : Joins two datasets after applying some functions to their name attributes.
+ *                  We expect the join to be transformed into a hybrid-hash join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+insert into t1
+select element {'name':'John Doe'};
+insert into t1
+select element {'name':'Jonathan'};
+insert into t1
+select element {'name':'Chen Li'};
+insert into t2
+select element {'name':'Jimmy King'};
+insert into t2
+select element {'name':'john doe'};
+insert into t2
+select element {'name':'CHEN LI'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.3.query.sqlpp
new file mode 100644
index 0000000..30e0699
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query_issue267/query_issue267.3.query.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.
+ */
+/*
+ * Description    : Joins two datasets after applying some functions to their name attributes.
+ *                  We expect the join to be transformed into a hybrid-hash join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element l
+from  t1 as l,
+      t2 as m
+where ((test.lowercase(m.name) = test.lowercase(l.name)) and (test."string-length"(m.name) = test."string-length"(l.name)))
+order by l.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.3.query.sqlpp
new file mode 100644
index 0000000..e5fa0c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/range_01/range_01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element x
+from  test.range(20,30) as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.1.ddl.sqlpp
new file mode 100644
index 0000000..481d063
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.1.ddl.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.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  05/18/2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.2.update.sqlpp
new file mode 100644
index 0000000..742823b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  05/18/2014
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.3.query.sqlpp
new file mode 100644
index 0000000..dbcb4f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/stable_sort/stable_sort.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :  Test for clause of the position variable in FLWOR expression
+ * Expected Result  :  Success
+ * Date             :  05/18/2014
+ */
+
+use test;
+
+
+select element i
+from  LineItem as i
+order by i.l_partkey desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.1.ddl.sqlpp
new file mode 100644
index 0000000..c6e07b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbUserAliasIdx  on FacebookUsers (alias) type ngram (3);
+
+create  index fbUserNameIdx2  on FacebookUsers (name) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.2.update.sqlpp
new file mode 100644
index 0000000..699f515
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.2.update.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 TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.3.query.sqlpp
new file mode 100644
index 0000000..c602f6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/string_eq_01/string_eq_01.3.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  FacebookUsers as user
+where (user.alias = 'Isbel')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.3.query.sqlpp
new file mode 100644
index 0000000..44a7125
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/tid_01/tid_01.3.query.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 element i
+from  ['a','b','c'] as x at i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.3.query.sqlpp
new file mode 100644
index 0000000..4771df1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/year_01/year_01.3.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;
+
+
+select element test."get-year"('1996-12-01');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ddl.sqlpp
new file mode 100644
index 0000000..679322e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : compact-dataset-and-its-indexes.aql
+ * Description     : This test is intended to test the compact statement which merge the disk components of a dataset and
+ * all of its indexes.
+ * Expected Result : Success
+ * Date            : Sep 19 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemTypetmp as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemType as
+ closed {
+  nested : LineItemTypetmp
+}
+
+create  table LineItemtmp(LineItemTypetmp) primary key l_orderkey,l_linenumber;
+
+create  table LineItem(LineItemType) primary key nested.l_orderkey,nested.l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.update.sqlpp
new file mode 100644
index 0000000..e04e23d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItemtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineItem
+select element {'nested':c}
+from  LineItemtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ddl.sqlpp
new file mode 100644
index 0000000..6114030
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ddl.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.
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (nested.l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (nested.l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.update.sqlpp
new file mode 100644
index 0000000..481e443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.update.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;
+
+
+delete l from LineItem
+ where ((l.nested.l_suppkey >= 2) or (l.nested.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.query.sqlpp
new file mode 100644
index 0000000..a7f3a3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  LineItem as c
+where (c.nested.l_suppkey < 150)
+order by c.nested.l_orderkey,c.nested.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..4e88d27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.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.
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..939730e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.sqlpp
new file mode 100644
index 0000000..b8bad1b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.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.
+ */
+
+use TinySocial;
+
+
+create  index stat  on TweetMessages (user.statuses_count) type btree;
+
+create  index name  on TweetMessages (user.name) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp
new file mode 100644
index 0000000..6f40734
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.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 TinySocial;
+
+
+delete l from TweetMessages
+ where ((l.user.name >= 'Oli Jackson') or (l.user.statuses_count > 362));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp
new file mode 100644
index 0000000..71b8ac8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.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.
+ */
+
+use TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where (c.user.statuses_count < 473)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-syntax-change.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-syntax-change.sqlpp
new file mode 100644
index 0000000..576e434
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/delete-syntax-change.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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  : Test variant syntax for delete
+ *              : Ending semi-colon is optional for delete
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+delete l from LineItem
+ where (l.l_orderkey >= 10);
+write output to nc1:"rttest/dml_delete-syntax-change.adm"
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.1.ddl.sqlpp
new file mode 100644
index 0000000..11f0d4d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.1.ddl.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schematmp as
+ closed {
+  unique1 : int64,
+  unique2 : int64,
+  two : int64,
+  four : int64,
+  ten : int64,
+  twenty : int64,
+  onePercent : int64,
+  tenPercent : int64,
+  twentyPercent : int64,
+  fiftyPercent : int64,
+  unique3 : int64,
+  evenOnePercent : int64,
+  oddOnePercent : int64,
+  stringu1 : string,
+  stringu2 : string,
+  string4 : string
+}
+
+create type test.Schema as
+ closed {
+  nested : Schematmp
+}
+
+create  table t1tmp(Schematmp) primary key unique2;
+
+create  table t1(Schema) primary key nested.unique2;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.2.update.sqlpp
new file mode 100644
index 0000000..b8805d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.2.update.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.
+ */
+/*
+ * Description     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+use test;
+
+
+load  table t1tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/wisc/onektup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into t1
+select element {'nested':c}
+from  t1tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.3.ddl.sqlpp
new file mode 100644
index 0000000..cbb4ef5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.3.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.
+ */
+
+use test;
+
+
+create  index idx_t1_str1  on t1 (nested.stringu1) type btree;
+
+create  index idx_t1_unique1  on t1 (nested.unique1) type btree;
+
+drop index t1.idx_t1_str1;
+drop index t1.idx_t1_unique1;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.4.query.sqlpp
new file mode 100644
index 0000000..31b2151
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/drop-index/drop-index.4.query.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.
+ */
+/*
+ * Description     : Drop secondary index.
+ * Expected Result : Success
+ * Date            : 12th July 2012
+ *
+ */
+
+use test;
+
+
+select element a.nested
+from  t1 as a
+where ((a.nested.unique1 > 10) and (a.nested.stringu1 = 'DGAAAAXXXXXXXXXXXXXXXXXXX'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..4aa1317
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ddl.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.
+ */
+/*
+ * Test case Name  : insert-into-empty-dataset-with-index.aql
+ * Description     : Check that we can insert into an empty dataset and its empty secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index idx_LineID_partkey  on TweetMessages (user.name) type btree;
+
+create  index idx_LineID_suppkey  on TweetMessages (user.statuses_count) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..a13385e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.update.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.
+ */
+/*
+ * Test case Name  : insert-into-empty-dataset-with-index.aql
+ * Description     : Check that we can insert into an empty dataset and its empty secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use TinySocial;
+
+
+insert into TweetMessages
+select element {'tweetid':'1','user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':TinySocial.point('47.44,80.65'),'send-time':TinySocial.datetime('2008-04-26T10:10:00'),'referred-topics':{{'t-mobile','customization'}},'message-text':' love t-mobile its customization is good:)'};
+insert into TweetMessages
+select element {'tweetid':'12','user':{'screen-name':'OliJackson_512','lang':'en','friends_count':445,'statuses_count':164,'name':'Oli Jackson','followers_count':22649},'sender-location':TinySocial.point('24.82,94.63'),'send-time':TinySocial.datetime('2010-02-13T10:10:00'),'referred-topics':{{'samsung','voice-command'}},'message-text':' like samsung the voice-command is amazing:)'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.query.sqlpp
new file mode 100644
index 0000000..1684be2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.query.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.
+ */
+/*
+ * Test case Name  : insert-into-empty-dataset-with-index.aql
+ * Description     : Check that we can insert into an empty dataset and its empty secondary indexes
+ * Expected Result : Success
+ * Date            : May 2 2012
+ */
+
+use TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where ((c.user.name >= 'Nathan Giesen') and (c.user.statuses_count > 164))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4e88d27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ddl.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.
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.update.sqlpp
new file mode 100644
index 0000000..939730e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ddl.sqlpp
new file mode 100644
index 0000000..d53900b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ddl.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.
+ */
+
+use TinySocial;
+
+
+create  index idx_LineID_partkey  on TweetMessages (user.name) type btree;
+
+create  index idx_LineID_suppkey  on TweetMessages (user.statuses_count) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.update.sqlpp
new file mode 100644
index 0000000..a2bf719
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.update.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.
+ */
+
+use TinySocial;
+
+
+insert into TweetMessages
+select element {'tweetid':'13','user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':TinySocial.point('47.44,80.65'),'send-time':TinySocial.datetime('2008-04-26T10:10:00'),'referred-topics':{{'t-mobile','customization'}},'message-text':' love t-mobile its customization is good:)'};
+insert into TweetMessages
+select element {'tweetid':'14','user':{'screen-name':'OliJackson_512','lang':'en','friends_count':445,'statuses_count':164,'name':'Oli Jackson','followers_count':22649},'sender-location':TinySocial.point('24.82,94.63'),'send-time':TinySocial.datetime('2010-02-13T10:10:00'),'referred-topics':{{'samsung','voice-command'}},'message-text':' like samsung the voice-command is amazing:)'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.query.sqlpp
new file mode 100644
index 0000000..a809b6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where ((c.user.name = 'Nathan Giesen') and (c.user.statuses_count = 473))
+order by c.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4e88d27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ddl.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.
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.update.sqlpp
new file mode 100644
index 0000000..939730e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ddl.sqlpp
new file mode 100644
index 0000000..d53900b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ddl.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.
+ */
+
+use TinySocial;
+
+
+create  index idx_LineID_partkey  on TweetMessages (user.name) type btree;
+
+create  index idx_LineID_suppkey  on TweetMessages (user.statuses_count) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.update.sqlpp
new file mode 100644
index 0000000..a2bf719
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.update.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.
+ */
+
+use TinySocial;
+
+
+insert into TweetMessages
+select element {'tweetid':'13','user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39339,'statuses_count':473,'name':'Nathan Giesen','followers_count':49416},'sender-location':TinySocial.point('47.44,80.65'),'send-time':TinySocial.datetime('2008-04-26T10:10:00'),'referred-topics':{{'t-mobile','customization'}},'message-text':' love t-mobile its customization is good:)'};
+insert into TweetMessages
+select element {'tweetid':'14','user':{'screen-name':'OliJackson_512','lang':'en','friends_count':445,'statuses_count':164,'name':'Oli Jackson','followers_count':22649},'sender-location':TinySocial.point('24.82,94.63'),'send-time':TinySocial.datetime('2010-02-13T10:10:00'),'referred-topics':{{'samsung','voice-command'}},'message-text':' like samsung the voice-command is amazing:)'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.query.sqlpp
new file mode 100644
index 0000000..0311edd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.query.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.
+ */
+
+use TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where ((c.user.name < 'Nathan Giesen') and (c.user.statuses_count < 473))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-syntax.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-syntax.sqlpp
new file mode 100644
index 0000000..bda00e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/insert-syntax.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.
+ */
+/*
+ * Test case Name  : insert-syntax-change.aql
+ * Description     : verify various AQL syntax for insert
+ * Expected Result : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype as
+{
+  id : int32,
+  name : string
+}
+
+create  table testds(testtype) primary key id;
+
+insert into testds
+select element {'id':1,'name':'Person One','hobbies':{{'Rock','Metal'}}};
+insert into testds
+select element {'id':2,'name':'Person Two','hobbies':{{'Rock','Jazz'}}};
+insert into testds
+select element {'id':3,'name':'Person Three','hobbies':{{'Blues'}}};
+insert into testds
+select element {'id':4,'name':'Person Four','hobbies':{{'Metal','Jazz'}}};
+write output to nc1:"rttest/dml_insert-syntax.adm"
+select element d
+from  testds as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..64abdf5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  user : TwitterUserType,
+  tweetid : int64,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index idx_LineID_partkey  on TweetMessages (user.name) type btree;
+
+create  index idx_LineID_suppkey  on TweetMessages (user.statuses_count) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.2.update.sqlpp
new file mode 100644
index 0000000..06ef028
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm-nested.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.3.query.sqlpp
new file mode 100644
index 0000000..f551c93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-index/load-with-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where ((c.user.name < 'Nathan Giesen') and (c.user.statuses_count < 473))
+order by c.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.1.ddl.sqlpp
new file mode 100644
index 0000000..a9f2a15
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  user : TwitterUserType,
+  tweetid : int64,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index ngram_index  on TweetMessages (user.name) type ngram (3);
+
+create  index ngram_index1  on TweetMessages (user."screen-name") type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.2.update.sqlpp
new file mode 100644
index 0000000..06ef028
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm-nested.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.3.query.sqlpp
new file mode 100644
index 0000000..430a254
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where TinySocial.contains(c.user.name,'Nathan')
+order by c.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..083cbe6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64,
+  "sender-location" : point?
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  user : TwitterUserType,
+  tweetid : int64,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index rtree_index_point  on TweetMessages (user."sender-location") type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..06ef028
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm-nested.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..c962afd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 TinySocial;
+
+
+select element c
+from  TweetMessages as c
+where TinySocial."spatial-intersect"(c.user."sender-location",TinySocial."create-rectangle"(TinySocial."create-point"(0.0,0.0),TinySocial."create-point"(50.0,80.0)))
+order by c.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.1.ddl.sqlpp
new file mode 100644
index 0000000..429fafe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  user : TwitterUserType,
+  tweetid : int64,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index ngram_index  on TweetMessages (user.name) type keyword;
+
+create  index ngram_index1  on TweetMessages (user."screen-name") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.2.update.sqlpp
new file mode 100644
index 0000000..06ef028
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.2.update.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 TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm-nested.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.3.query.sqlpp
new file mode 100644
index 0000000..8f45141
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use TinySocial;
+
+
+select element c
+from  TweetMessages as c
+with  jacc as TinySocial."similarity-jaccard-check"(TinySocial."word-tokens"(c.user.name),TinySocial."word-tokens"('Nathan Giesen'),0.500000f)
+where jacc[0]
+order by c.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.1.ddl.sqlpp
new file mode 100644
index 0000000..66b29f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : nested-uuid
+ * Description     : tests creation of nested uuid against manual insert
+ * all of its indexes.
+ * Expected Result : Success
+ * Date            : Nov 24 2014
+ */
+
+drop  database twitter if exists;
+create  database twitter;
+
+use twitter;
+
+
+create type twitter.TweetMessageType as
+ closed {
+  id : uuid,
+  "message-text" : string
+}
+
+create type twitter."nest" as
+ closed {
+  nested : TweetMessageType
+}
+
+create type twitter.doublenest as
+ closed {
+  nested : "nest"
+}
+
+create  table doublenests(doublenest) primary key nested.nested.id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.2.update.sqlpp
new file mode 100644
index 0000000..17b6096
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.2.update.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 twitter;
+
+
+insert into doublenests
+select element {'nested':{'nested':{'message-text':'hello'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.3.query.sqlpp
new file mode 100644
index 0000000..f66e0fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.3.query.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 twitter;
+
+
+select element test.nested.nested."message-text"
+from  doublenests as test
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.1.ddl.sqlpp
new file mode 100644
index 0000000..bd13034
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : nested-uuid
+ * Description     : tests creation of nested uuid against manual insert
+ * all of its indexes.
+ * Expected Result : Success
+ * Date            : Nov 24 2014
+ */
+
+drop  database twitter if exists;
+create  database twitter;
+
+use twitter;
+
+
+create type twitter.TwitterUserType as
+{
+  userid : uuid,
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type twitter.TweetMessageType as
+ closed {
+  user : TwitterUserType,
+  tweetid : int64,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key user.userid autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.2.update.sqlpp
new file mode 100644
index 0000000..e19a21f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.2.update.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 twitter;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tinysocial/twm-nested.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.3.query.sqlpp
new file mode 100644
index 0000000..e8fca59
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.3.query.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.
+ */
+
+use twitter;
+
+
+select element {'tweetid':test.tweetid,'screen-name':test.user."screen-name"}
+from  TweetMessages as test
+order by test.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..aa47f17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customerstmp(CustomerTypetmp) primary key cid;
+
+create  table Customers(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..d3da93d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..d37ddad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ddl.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;
+
+
+create  index age_index  on Customers (nested.age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..014a578
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.update.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;
+
+
+delete c from Customers
+ where (c.nested.cid >= 200);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..6a9a8f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element c.nested
+from  Customers as c
+where (c.nested.age < 20)
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..bdf644e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..3c897c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..c57941c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..ef88973
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.nested.id > 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..5327757
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..c4049dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..c3e1780
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..e7521da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..8be2b45
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.nested.id > 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..fbae33d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..5c28f42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..7d18e7c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..64629e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..dde942d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.nested.id < 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..dc7f371
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..61a1a10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..8d187e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..4a0934c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..c2eb9d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+delete o from DBLP
+ where (o.nested.id < 50);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..a5be918
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test deletion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..a572058
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ddl.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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point?,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..86ebc72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm")) pre-sorted;
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..5683fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..ec7f98c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.update.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;
+
+
+delete m from MyData
+ where (m.nested.id > 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..4b7576a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test deletion from secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..dd8363d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..66a2496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.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.
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..5683fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..ec7f98c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.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;
+
+
+delete m from MyData
+ where (m.nested.id > 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..6830818
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..c6ddcf5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  table Customerstmp(CustomerTypetmp) primary key cid;
+
+create  table CustomersMinitmp(CustomerTypetmp) primary key cid;
+
+create  table CustomersMini(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..7f80a0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..dfdd06a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ddl.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.
+ */
+
+use test;
+
+
+create  index age_index  on CustomersMini (nested.age) type btree;
+
+create  index age_index  on CustomersMinitmp (age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..0f214b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+insert into CustomersMinitmp
+select element {'cid':c.cid,'name':c.name,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}
+from  Customerstmp as c
+where (c.cid < 200)
+;
+insert into CustomersMini
+select element {'nested':c}
+from  CustomersMinitmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..09ecda0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-delete-btree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary btree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element c.nested
+from  CustomersMini as c
+where (c.nested.age < 20)
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..4602b29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..ecf0f3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..ec0c3eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLPtmp (title) type ngram (3);
+
+create  index ngram_index1  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..c8a6573
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP
+select element {'nested':{'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}}
+from  DBLPtmp as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..46a9ef5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..5b71a68
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..d5b2d28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..a6ed712
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLPtmp (title) type ngram (3);
+
+create  index ngram_index1  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..f4ab6cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP
+select element {'nested':{'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}}
+from  DBLPtmp as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..3ef5226
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-ngram-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary ngram inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..9e16546
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string?,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..3bf5703
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-nulls.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..6aac003
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLPtmp (title) type keyword;
+
+create  index keyword_index1  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..88e2cdf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP
+select element {'nested':{'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}}
+from  DBLPtmp as o
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..489c933
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index that are built on nullable fields.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..aa0e1bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..dea125f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..888c6f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ddl.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLPtmp (title) type keyword;
+
+create  index keyword_index1  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..dc04528
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+insert into DBLP
+select element {'nested':{'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}}
+from  DBLPtmp as o
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..ac55eb0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-inverted-index-word-secondary-index.aql
+ * Description     : This test is intended to test insertion from secondary keyword inverted index.
+ * Expected Result : Success
+ * Date            : March 31 2013
+ */
+
+use test;
+
+
+select element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..30d69eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ddl.sqlpp
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point?,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyMiniRecordtmp as
+ closed {
+  id : int64,
+  point : point?
+}
+
+create type test.MyMiniRecord as
+ closed {
+  nested : MyMiniRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..e4be2b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.update.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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..e16f2a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ddl.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.
+ */
+
+use test;
+
+
+create  table MyMiniData(MyMiniRecord) primary key nested.id;
+
+create  index rtree_index_point  on MyMiniData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.update.sqlpp
new file mode 100644
index 0000000..25bdd43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.update.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.
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'nested':{'id':m.id,'point':m.point}}
+from  MyDatatmp as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.query.sqlpp
new file mode 100644
index 0000000..e463096
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.query.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.
+ */
+/*
+ * Test case Name  : scan-insert-rtree-secondary-index-nullable.aql
+ * Description     : This test is intended to test insertion into secondary rtree indexes that are built on nullable fields
+ * Expected Result : Success
+ * Date            : May 12 2012
+ */
+
+use test;
+
+
+select element {'id':o.nested.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..e927a93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyMiniRecordtmp as
+ closed {
+  id : int64,
+  point : point
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create type test.MyMiniRecord as
+ closed {
+  nested : MyMiniRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyMiniDatatmp(MyMiniRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
+create  table MyMiniData(MyMiniRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..e65eef7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.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.
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyMiniDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted;
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+;
+insert into MyMiniData
+select element {'nested':c}
+from  MyMiniDatatmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..487e9dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.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.
+ */
+
+use test;
+
+
+create  index rtree_index_point_0  on MyData (nested.point) type rtree;
+
+create  index rtree_index_point  on MyMiniData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..8cab35d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.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.
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'nested':{'id':m.nested.id,'point':m.nested.point}}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..6dac176
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.1.ddl.sqlpp
new file mode 100644
index 0000000..edc8dee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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  : Create an external dataset that contains records stored with text hdfs file format.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNested as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordNested
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialDataNested.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index idx  on MyData (nested.id) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.2.update.sqlpp
new file mode 100644
index 0000000..5964b88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.3.query.sqlpp
new file mode 100644
index 0000000..6f0d270
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/adm-format/adm-format.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
+use test;
+
+
+select element {'id':d.nested.id,'point':d.nested.point,'kwds':d.nested.kwds,'line1':d.nested.line1,'line2':d.nested.line2,'poly1':d.nested.poly1,'poly2':d.nested.poly2,'rec':d.nested.rec,'circle':d.nested.circle}
+from  MyData as d
+where (d.nested.id = 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
new file mode 100644
index 0000000..9e32a84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin_nested.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (nested.tweetid) type btree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
new file mode 100644
index 0000000..222d5d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.nested."sender-location",n)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
new file mode 100644
index 0000000..92ff6da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin_nested.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (nested.tweetid) type btree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
new file mode 100644
index 0000000..90607b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
new file mode 100644
index 0000000..b00c064
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.3.query.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.
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..2757d8e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNested as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordNested
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialDataNested.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index rtree_index_point  on MyData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..e72d774
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ddl.sqlpp
new file mode 100644
index 0000000..4c63f98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ddl.sqlpp
@@ -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.
+ */
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  cashBack : int64,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderTypetmp as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float,
+  items : [int64]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create type test.OrderType as
+{
+  nested : OrderTypetmp
+}
+
+create  table Customerstmp(CustomerTypetmp) primary key cid;
+
+create  table Orderstmp(OrderTypetmp) primary key oid;
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Orders(OrderType) primary key nested.oid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.2.update.sqlpp
new file mode 100644
index 0000000..df9022e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/customerData.json"),("format"="adm"));
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/orderData.json"),("format"="adm"));
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+;
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.3.query.sqlpp
new file mode 100644
index 0000000..0e80521
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.3.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, Customers and Orders, based on the customer id.
+ *                  Given the 'indexnl' hint we expect the join to be transformed
+ *                  into an indexed nested-loop join using Customers' primary index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'cid':c.nested.cid,'oid':o.nested.oid}
+from  Customers as c,
+      Orders as o
+where (c.nested.cid /*+ indexnl */  = o.nested.cid)
+order by c.nested.cid,o.nested.oid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp
new file mode 100644
index 0000000..1905215
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table CSXtmp(CSXTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp
new file mode 100644
index 0000000..3e3f2b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp
new file mode 100644
index 0000000..1352b5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index title_index  on DBLP (nested.authors) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.sqlpp
new file mode 100644
index 0000000..d75666d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.nested.id,'bid':b.nested.id,'authors':a.nested.authors}
+from  DBLP as a,
+      CSX as b
+where (a.nested.authors /*+ indexnl */  = b.nested.authors)
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..cec394a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerNestedType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerNestedType
+}
+
+create  table Customerstmp(CustomerNestedType) primary key cid;
+
+create  table Customers2tmp(CustomerNestedType) primary key cid;
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..0f540c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
+insert into Customers2
+select element {'nested':c}
+from  Customers2tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..ffa1be1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (nested.name) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..8ea4c98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.nested.name,b.nested.name)
+where ((ed <= 4) and (a.nested.cid < b.nested.cid))
+order by ed,a.nested.cid,b.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..240a381
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerNestedType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerNestedType
+}
+
+create  table Customerstmp(CustomerNestedType) primary key cid;
+
+create  table Customers2tmp(CustomerNestedType) primary key cid;
+
+create  table Customers(CustomerType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..a700fa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
+insert into Customers2
+select element {'nested':c}
+from  Customers2tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..b6ad62d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (nested.name) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..0041e79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.nested.name,b.nested.name) <= 4) and (a.nested.cid < b.nested.cid))
+order by a.nested.cid,b.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..0dac990
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create type test.CSXNestedType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXNestedType
+}
+
+create  table DBLPtmp(DBLPNestedType) primary key id;
+
+create  table CSXtmp(CSXNestedType) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..f6ba2ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..4235702
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..12c6c62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a.nested,'brec':b.nested,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+order by jacc,a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..27b94a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create type test.CSXNestedType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXNestedType
+}
+
+create  table DBLPtmp(DBLPNestedType) primary key id;
+
+create  table CSXtmp(CSXNestedType) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..1c23233
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..97d5028
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..3c82687
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a.nested,'brec':b.nested}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
new file mode 100644
index 0000000..bf29aca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.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.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create  table MyData1tmp(MyRecordtmp) primary key id;
+
+create  table MyData2tmp(MyRecordtmp) primary key id;
+
+create  table MyData1(MyRecord) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
new file mode 100644
index 0000000..dfc0abe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table MyData1tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyData2tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into MyData1
+select element {'nested':c}
+from  MyData1tmp as c
+;
+insert into MyData2
+select element {'nested':c}
+from  MyData2tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
new file mode 100644
index 0000000..9c37177
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index rtree_index  on MyData1 (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp
new file mode 100644
index 0000000..54ac005
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.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.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.nested.id,'bid':b.nested.id,'apt':a.nested.point,'bp':b.nested.point}
+from  MyData1 as a,
+      MyData2 as b
+where (test."spatial-intersect"(a.nested.point,b.nested.point) and (a.nested.id != b.nested.id))
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..a578575
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create type test.CSXNestedType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXNestedType
+}
+
+create  table DBLPtmp(DBLPNestedType) primary key id;
+
+create  table CSXtmp(CSXNestedType) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..d5ba1ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..0023f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..392af74
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+order by jacc,a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..dbf20c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create type test.CSXNestedType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXNestedType
+}
+
+create  table DBLPtmp(DBLPNestedType) primary key id;
+
+create  table CSXtmp(CSXNestedType) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..6eb660c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..9e07f4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..6ec138a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..8c86c33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..c4051dba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..ad8a8fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..8c86c33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..c4051dba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..70eb760
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where ((t1.nested.countA /*+ indexnl */  = t2.nested.countB) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..715c3bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+create  index msgNgramIx  on TweetMessages (nested."message-text") type ngram (3);
+
+create  index topicKeywordIx  on TweetMessages (nested."referred-topics") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..c4051dba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..d935d25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use test;
+
+
+select element {'tweet':{'id':t1.nested.tweetid,'topics':t1.nested."referred-topics"},'similar-tweets':(
+        select element {'id':t2.nested.tweetid,'topics':t2.nested."referred-topics"}
+        from  TweetMessages as t2
+        with  sim as test."similarity-jaccard-check"(t1.nested."referred-topics",t2.nested."referred-topics",0.500000f)
+        where (sim[0] and (t2.nested.tweetid != t1.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid > test.int64('240'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..715c3bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
+create  index msgNgramIx  on TweetMessages (nested."message-text") type ngram (3);
+
+create  index topicKeywordIx  on TweetMessages (nested."referred-topics") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..c4051dba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..824cd4b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use test;
+
+
+select element {'tweet':{'id':t1.nested.tweetid,'topics':t1.nested."message-text"},'similar-tweets':(
+        select element {'id':t2.nested.tweetid,'topics':t2.nested."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1.nested."message-text",t2.nested."message-text",7)
+        where (sim[0] and (t2.nested.tweetid != t1.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid > test.int64('240'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..9cc01a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..d3bad02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..e52aba9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.nested."sender-location",n)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..9cc01a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+ closed {
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location") type rtree;
+
+create  index msgCountAIx  on TweetMessages (nested.countA) type btree;
+
+create  index msgCountBIx  on TweetMessages (nested.countB) type btree;
+
+create  index msgTextIx  on TweetMessages (nested."message-text") type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..d3bad02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..f6bd22f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2.nested."sender-location",n) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
new file mode 100644
index 0000000..00e6a3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpTmp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.Nested as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.Emp as
+ closed {
+  nested : Nested
+}
+
+create  table employeeTmp(EmpTmp) primary key id;
+
+create  table employee(Emp) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
new file mode 100644
index 0000000..51175a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
@@ -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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+load  table employeeTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into employee
+select element {'nested':{'id':c.id,'fname':c.fname,'lname':c.lname,'age':c.age,'dept':c.dept}}
+from  employeeTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.sqlpp
new file mode 100644
index 0000000..69f2a55
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.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;
+
+
+create  index idx_employee_f_l_name  on employee (nested.fname,nested.lname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp
new file mode 100644
index 0000000..a3ed473
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+select element l.nested
+from  employee as l
+where ((l.nested.fname > 'Julio') and (l.nested.lname > 'Mattocks') and (l.nested.fname <= 'Micco') and (l.nested.lname < 'Vangieson'))
+order by l.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
new file mode 100644
index 0000000..628b2f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpTmp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.Nested as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.Emp as
+ closed {
+  nested : Nested
+}
+
+create  table employeeTmp(EmpTmp) primary key id;
+
+create  table employee(Emp) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
new file mode 100644
index 0000000..b47ca19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+load  table employeeTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into employee
+select element {'nested':{'id':c.id,'fname':c.fname,'lname':c.lname,'age':c.age,'dept':c.dept}}
+from  employeeTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp
new file mode 100644
index 0000000..f91acaa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+create  index idx_employee_f_l_name  on employee (nested.fname,nested.lname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp
new file mode 100644
index 0000000..67128d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+select element l.nested
+from  employee as l
+where ((l.nested.fname = 'Julio') and (l.nested.lname = 'Isa'))
+order by l.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
new file mode 100644
index 0000000..bcfc2ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+{
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.Nested as
+{
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+{
+  nested : Nested
+}
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
new file mode 100644
index 0000000..2bee895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':{'o_orderkey':c.o_orderkey,'o_custkey':c.o_custkey,'o_orderstatus':c.o_orderstatus,'o_totalprice':c.o_totalprice,'o_orderdate':c.o_orderdate,'o_orderpriority':c.o_orderpriority,'o_clerk':c.o_clerk,'o_shippriority':c.o_shippriority,'o_comment':c.o_comment}}
+from  Orderstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp
new file mode 100644
index 0000000..bca9519
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
new file mode 100644
index 0000000..7b0ea32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey,'o_orderstatus':o.nested.o_orderstatus,'o_orderkey2':o2.nested.o_orderkey,'o_custkey2':o2.nested.o_custkey,'o_orderstatus2':o2.nested.o_orderstatus}
+from  Orders as o,
+      Orders as o2
+where ((o.nested.o_custkey = 20) and (o2.nested.o_custkey = 10) and (o.nested.o_orderstatus < o2.nested.o_orderstatus))
+order by o.nested.o_orderkey,o2.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..383f24c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+{
+  nested : CustomerTypetmp
+}
+
+create  table Customerstmp(CustomerTypetmp) primary key cid;
+
+create  table Customers(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.update.sqlpp
new file mode 100644
index 0000000..f9b7089
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.update.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.
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/tiny01/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..d37ddad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ddl.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;
+
+
+create  index age_index  on Customers (nested.age) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.query.sqlpp
new file mode 100644
index 0000000..51aad72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  Customers as c
+where (c.nested.age < 20)
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..bf81d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp
new file mode 100644
index 0000000..f1adfc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..7bfd80a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
new file mode 100644
index 0000000..4ac54d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..850bbdf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create  table DBLPtmp(DBLPNestedType) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp
new file mode 100644
index 0000000..5ef2813
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLP
+select element {'nested':x}
+from  "test.DBLPtmp" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..7bfd80a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
new file mode 100644
index 0000000..0ae9ee8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper
+where test."edit-distance-contains"(paper.nested.title,'Multmedia',1)[0]
+order by paper.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
new file mode 100644
index 0000000..bf81d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp
new file mode 100644
index 0000000..f1adfc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp
new file mode 100644
index 0000000..dc76fdb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
new file mode 100644
index 0000000..b5c7ee0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
new file mode 100644
index 0000000..e204dd1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPNestedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create type test.DBLPType as
+ closed {
+  nested : DBLPNestedType
+}
+
+create  table DBLPtmp(DBLPNestedType) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp
new file mode 100644
index 0000000..5ef2813
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLP
+select element {'nested':x}
+from  "test.DBLPtmp" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp
new file mode 100644
index 0000000..7bfd80a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
new file mode 100644
index 0000000..a4b4a61
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.nested.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+order by paper.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..bf81d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..f1adfc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..dc76fdb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.authors) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..dbdbfe7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..bf81d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..f1adfc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..7bfd80a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title) type ngram (3);
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..ac1af89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.sqlpp
new file mode 100644
index 0000000..7596762
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customerstmp(CustomerTypetmp) primary key cid on group1;
+
+create  table Customers(CustomerType) primary key nested.cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.update.sqlpp
new file mode 100644
index 0000000..77a1f4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.update.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.
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ddl.sqlpp
new file mode 100644
index 0000000..002cec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ddl.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;
+
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.query.sqlpp
new file mode 100644
index 0000000..62b2149
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element c.nested
+from  Customers as c
+with  ed as test."edit-distance-check"(c.nested.interests,['computers','wine','walking'],3)
+where ed[0]
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..7596762
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customerstmp(CustomerTypetmp) primary key cid on group1;
+
+create  table Customers(CustomerType) primary key nested.cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..77a1f4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.update.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.
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..002cec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ddl.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;
+
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..c371967
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element c.nested
+from  Customers as c
+with  ed as test."edit-distance-check"(c.nested.interests,['computers','wine','walking'],1)
+where ed[0]
+order by c.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..7596762
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customerstmp(CustomerTypetmp) primary key cid on group1;
+
+create  table Customers(CustomerType) primary key nested.cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..77a1f4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..002cec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ddl.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;
+
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..a57ab13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.nested.interests,['databases','computers','wine'],0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..af3d325
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+ closed {
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerTypetmp as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1
+;
+create  table Customerstmp(CustomerTypetmp) primary key cid on group1;
+
+create  table Customers(CustomerType) primary key nested.cid on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..d8e7e6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..002cec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ddl.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;
+
+
+create  index interests_index  on Customers (nested.interests) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..0380a9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  Customers as c
+with  jacc as test."similarity-jaccard-check"(c.nested.interests,{{'computers','wine','databases'}},0.700000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..bf81d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp
new file mode 100644
index 0000000..f1adfc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..5c1578a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.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;
+
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
new file mode 100644
index 0000000..4ac54d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..bf81d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPTypetmp
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..f1adfc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..5c1578a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.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;
+
+
+create  index keyword_index  on DBLP (nested.title) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..bb34fa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ddl.sqlpp
new file mode 100644
index 0000000..55e8c1b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+{
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.update.sqlpp
new file mode 100644
index 0000000..4af2c27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ddl.sqlpp
new file mode 100644
index 0000000..bca9519
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.query.sqlpp
new file mode 100644
index 0000000..05455bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey}
+from  Orders as o
+where ((o.nested.o_custkey = 40) and (o.nested.o_totalprice > 150000.0))
+order by o.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
new file mode 100644
index 0000000..7aa5e02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp
new file mode 100644
index 0000000..4af2c27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp
new file mode 100644
index 0000000..bca9519
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
new file mode 100644
index 0000000..05455bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey}
+from  Orders as o
+where ((o.nested.o_custkey = 40) and (o.nested.o_totalprice > 150000.0))
+order by o.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ddl.sqlpp
new file mode 100644
index 0000000..7aa5e02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.update.sqlpp
new file mode 100644
index 0000000..4af2c27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ddl.sqlpp
new file mode 100644
index 0000000..bca9519
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.query.sqlpp
new file mode 100644
index 0000000..2316399
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey}
+from  Orders as o
+where (o.nested.o_custkey = 40)
+order by o.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
new file mode 100644
index 0000000..7aa5e02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : OrderTypetmp
+}
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp
new file mode 100644
index 0000000..4af2c27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp
new file mode 100644
index 0000000..bca9519
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
new file mode 100644
index 0000000..2316399
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey}
+from  Orders as o
+where (o.nested.o_custkey = 40)
+order by o.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.1.ddl.sqlpp
new file mode 100644
index 0000000..696d61e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemTypetmp as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemType as
+ closed {
+  nested : LineItemTypetmp
+}
+
+create  table LineItemtmp(LineItemTypetmp) primary key l_orderkey,l_linenumber;
+
+create  table LineItem(LineItemType) primary key nested.l_orderkey,nested.l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.2.update.sqlpp
new file mode 100644
index 0000000..e04e23d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItemtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineItem
+select element {'nested':c}
+from  LineItemtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.3.ddl.sqlpp
new file mode 100644
index 0000000..c4cb9bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.3.ddl.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;
+
+
+create  index idx_LineItem_suppkey  on LineItem (nested.l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.4.query.sqlpp
new file mode 100644
index 0000000..37f904b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search-open/range-search-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  LineItem as c
+where ((c.nested.l_suppkey < 100) and (c.nested.l_suppkey > 5))
+order by c.nested.l_orderkey,c.nested.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.1.ddl.sqlpp
new file mode 100644
index 0000000..696d61e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemTypetmp as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemType as
+ closed {
+  nested : LineItemTypetmp
+}
+
+create  table LineItemtmp(LineItemTypetmp) primary key l_orderkey,l_linenumber;
+
+create  table LineItem(LineItemType) primary key nested.l_orderkey,nested.l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.2.update.sqlpp
new file mode 100644
index 0000000..e04e23d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItemtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineItem
+select element {'nested':c}
+from  LineItemtmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.3.ddl.sqlpp
new file mode 100644
index 0000000..c4cb9bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.3.ddl.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;
+
+
+create  index idx_LineItem_suppkey  on LineItem (nested.l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.4.query.sqlpp
new file mode 100644
index 0000000..37f904b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/range-search/range-search.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  LineItem as c
+where ((c.nested.l_suppkey < 100) and (c.nested.l_suppkey > 5))
+order by c.nested.l_orderkey,c.nested.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..07b2d9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point?,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.update.sqlpp
new file mode 100644
index 0000000..b0049f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.update.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.
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialDataNulls.json"),("format"="adm"));
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ddl.sqlpp
new file mode 100644
index 0000000..5683fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.query.sqlpp
new file mode 100644
index 0000000..e72d774
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ddl.sqlpp
new file mode 100644
index 0000000..8de9668
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+{
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecord as
+{
+  nested : MyRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.update.sqlpp
new file mode 100644
index 0000000..c6c62b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.update.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.
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ddl.sqlpp
new file mode 100644
index 0000000..5683fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.query.sqlpp
new file mode 100644
index 0000000..e72d774
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..dd8363d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..c6c62b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.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.
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..5683fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (nested.point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
new file mode 100644
index 0000000..e72d774
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.1.ddl.sqlpp
new file mode 100644
index 0000000..ffac14b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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  : Create an external dataset that contains records stored with text hdfs file format.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNested as
+{
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordNested
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialDataNested.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index idx  on MyData (nested.id:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.2.update.sqlpp
new file mode 100644
index 0000000..5964b88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.3.query.sqlpp
new file mode 100644
index 0000000..6f0d270
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
+use test;
+
+
+select element {'id':d.nested.id,'point':d.nested.point,'kwds':d.nested.kwds,'line1':d.nested.line1,'line2':d.nested.line2,'poly1':d.nested.poly1,'poly2':d.nested.poly2,'rec':d.nested.rec,'circle':d.nested.circle}
+from  MyData as d
+where (d.nested.id = 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
new file mode 100644
index 0000000..3c905e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
@@ -0,0 +1,64 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin_nested.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (nested.tweetid:int64) type btree enforced;
+
+create  index msgCountAIx  on TweetMessages (nested.countA:int64) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int64) type btree enforced;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location":point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
new file mode 100644
index 0000000..222d5d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.nested."sender-location",n)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
new file mode 100644
index 0000000..24011dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin_nested.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (nested.tweetid:int64) type btree enforced;
+
+create  index msgCountAIx  on TweetMessages (nested.countA:int64) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
new file mode 100644
index 0000000..90607b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
new file mode 100644
index 0000000..b00c064
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.3.query.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.
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..2528da0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNested as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordNested
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialDataNested.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index rtree_index_point  on MyData (nested.point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..e72d774
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.1.ddl.sqlpp
new file mode 100644
index 0000000..99a8166
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.1.ddl.sqlpp
@@ -0,0 +1,121 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+ closed {
+  id : int64,
+  Species : string
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+ closed {
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+ closed {
+  id : int64,
+  class : Classification
+}
+
+create  table Animals(Animal) primary key id;
+
+create  table Classifications(Classification) primary key id;
+
+create  table KPCOFGSs(KPCOFGS) primary key id;
+
+create  table Ss(S) primary key id;
+
+create  table GSs(GS) primary key id;
+
+create  table FGSs(FGS) primary key id;
+
+create  table OFGSs(OFGS) primary key id;
+
+create  table COFGSs(COFGS) primary key id;
+
+create  table PCOFGSs(PCOFGS) primary key id;
+
+create  index species  on Ss (Species) type btree;
+
+create  index genus  on GSs (lower.Species) type btree;
+
+create  index family  on FGSs (lower.lower.Species:string) type btree enforced;
+
+create  index orda  on OFGSs (lower.lower.lower.Species:string) type btree enforced;
+
+create  index classy  on COFGSs (lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on PCOFGSs (lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on KPCOFGSs (lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index class  on Classifications (fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index anim  on Animals (class.fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.2.update.sqlpp
new file mode 100644
index 0000000..f5277f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.2.update.sqlpp
@@ -0,0 +1,108 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+insert into Ss
+select element {'id':1,'Species':'Gulo'};
+insert into Ss
+select element {'id':2,'Species':'Johnstoni'};
+insert into GSs
+select element {'id':1,'Genus':'Gulo','lower':S}
+from  Ss as S
+where (S.Species = 'Gulo')
+;
+insert into GSs
+select element {'id':2,'Genus':'Okapia','lower':S}
+from  Ss as S
+where (S.Species = 'Johnstoni')
+;
+insert into FGSs
+select element {'id':1,'Family':'Mustelinae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Gulo')
+;
+insert into FGSs
+select element {'id':2,'Family':'Giraffidae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Johnstoni')
+;
+insert into OFGSs
+select element {'id':1,'Order':'Carnivora','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Gulo')
+;
+insert into OFGSs
+select element {'id':2,'Order':'Artiodactyla','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Johnstoni')
+;
+insert into COFGSs
+select element {'id':1,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Gulo')
+;
+insert into COFGSs
+select element {'id':2,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into PCOFGSs
+select element {'id':1,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into PCOFGSs
+select element {'id':2,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into KPCOFGSs
+select element {'id':1,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into KPCOFGSs
+select element {'id':2,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Classifications
+select element {'id':1,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Classifications
+select element {'id':2,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Animals
+select element {'id':1,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Animals
+select element {'id':2,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.3.query.sqlpp
new file mode 100644
index 0000000..59c0496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+select element test
+from  Animals as test
+where (test.class.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.1.ddl.sqlpp
new file mode 100644
index 0000000..f5d7d9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.1.ddl.sqlpp
@@ -0,0 +1,120 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+ closed {
+  id : int64,
+  Species : string
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+ closed {
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+{
+  id : int64
+}
+
+create  table Animals(Animal) primary key id;
+
+create  table Classifications(Classification) primary key id;
+
+create  table KPCOFGSs(KPCOFGS) primary key id;
+
+create  table Ss(S) primary key id;
+
+create  table GSs(GS) primary key id;
+
+create  table FGSs(FGS) primary key id;
+
+create  table OFGSs(OFGS) primary key id;
+
+create  table COFGSs(COFGS) primary key id;
+
+create  table PCOFGSs(PCOFGS) primary key id;
+
+create  index species  on Ss (Species) type btree;
+
+create  index genus  on GSs (lower.Species) type btree;
+
+create  index family  on FGSs (lower.lower.Species:string) type btree enforced;
+
+create  index orda  on OFGSs (lower.lower.lower.Species:string) type btree enforced;
+
+create  index classy  on COFGSs (lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on PCOFGSs (lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on KPCOFGSs (lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index class  on Classifications (fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index anim  on Animals (class.fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.2.update.sqlpp
new file mode 100644
index 0000000..f5277f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.2.update.sqlpp
@@ -0,0 +1,108 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+insert into Ss
+select element {'id':1,'Species':'Gulo'};
+insert into Ss
+select element {'id':2,'Species':'Johnstoni'};
+insert into GSs
+select element {'id':1,'Genus':'Gulo','lower':S}
+from  Ss as S
+where (S.Species = 'Gulo')
+;
+insert into GSs
+select element {'id':2,'Genus':'Okapia','lower':S}
+from  Ss as S
+where (S.Species = 'Johnstoni')
+;
+insert into FGSs
+select element {'id':1,'Family':'Mustelinae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Gulo')
+;
+insert into FGSs
+select element {'id':2,'Family':'Giraffidae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Johnstoni')
+;
+insert into OFGSs
+select element {'id':1,'Order':'Carnivora','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Gulo')
+;
+insert into OFGSs
+select element {'id':2,'Order':'Artiodactyla','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Johnstoni')
+;
+insert into COFGSs
+select element {'id':1,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Gulo')
+;
+insert into COFGSs
+select element {'id':2,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into PCOFGSs
+select element {'id':1,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into PCOFGSs
+select element {'id':2,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into KPCOFGSs
+select element {'id':1,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into KPCOFGSs
+select element {'id':2,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Classifications
+select element {'id':1,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Classifications
+select element {'id':2,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Animals
+select element {'id':1,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Animals
+select element {'id':2,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.3.query.sqlpp
new file mode 100644
index 0000000..59c0496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+select element test
+from  Animals as test
+where (test.class.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.1.ddl.sqlpp
new file mode 100644
index 0000000..c2837cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.1.ddl.sqlpp
@@ -0,0 +1,120 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+{
+  id : int64
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+ closed {
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+ closed {
+  id : int64,
+  class : Classification
+}
+
+create  table Animals(Animal) primary key id;
+
+create  table Classifications(Classification) primary key id;
+
+create  table KPCOFGSs(KPCOFGS) primary key id;
+
+create  table Ss(S) primary key id;
+
+create  table GSs(GS) primary key id;
+
+create  table FGSs(FGS) primary key id;
+
+create  table OFGSs(OFGS) primary key id;
+
+create  table COFGSs(COFGS) primary key id;
+
+create  table PCOFGSs(PCOFGS) primary key id;
+
+create  index species  on Ss (Species:string) type btree enforced;
+
+create  index genus  on GSs (lower.Species:string) type btree enforced;
+
+create  index family  on FGSs (lower.lower.Species:string) type btree enforced;
+
+create  index orda  on OFGSs (lower.lower.lower.Species:string) type btree enforced;
+
+create  index classy  on COFGSs (lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on PCOFGSs (lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on KPCOFGSs (lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index class  on Classifications (fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index anim  on Animals (class.fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.2.update.sqlpp
new file mode 100644
index 0000000..f5277f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.2.update.sqlpp
@@ -0,0 +1,108 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+insert into Ss
+select element {'id':1,'Species':'Gulo'};
+insert into Ss
+select element {'id':2,'Species':'Johnstoni'};
+insert into GSs
+select element {'id':1,'Genus':'Gulo','lower':S}
+from  Ss as S
+where (S.Species = 'Gulo')
+;
+insert into GSs
+select element {'id':2,'Genus':'Okapia','lower':S}
+from  Ss as S
+where (S.Species = 'Johnstoni')
+;
+insert into FGSs
+select element {'id':1,'Family':'Mustelinae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Gulo')
+;
+insert into FGSs
+select element {'id':2,'Family':'Giraffidae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Johnstoni')
+;
+insert into OFGSs
+select element {'id':1,'Order':'Carnivora','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Gulo')
+;
+insert into OFGSs
+select element {'id':2,'Order':'Artiodactyla','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Johnstoni')
+;
+insert into COFGSs
+select element {'id':1,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Gulo')
+;
+insert into COFGSs
+select element {'id':2,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into PCOFGSs
+select element {'id':1,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into PCOFGSs
+select element {'id':2,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into KPCOFGSs
+select element {'id':1,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into KPCOFGSs
+select element {'id':2,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Classifications
+select element {'id':1,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Classifications
+select element {'id':2,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Animals
+select element {'id':1,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Animals
+select element {'id':2,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.3.query.sqlpp
new file mode 100644
index 0000000..59c0496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+select element test
+from  Animals as test
+where (test.class.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.1.ddl.sqlpp
new file mode 100644
index 0000000..7b3ff12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.1.ddl.sqlpp
@@ -0,0 +1,119 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+{
+  id : int64
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+ closed {
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+{
+  id : int64
+}
+
+create  table Animals(Animal) primary key id;
+
+create  table Classifications(Classification) primary key id;
+
+create  table KPCOFGSs(KPCOFGS) primary key id;
+
+create  table Ss(S) primary key id;
+
+create  table GSs(GS) primary key id;
+
+create  table FGSs(FGS) primary key id;
+
+create  table OFGSs(OFGS) primary key id;
+
+create  table COFGSs(COFGS) primary key id;
+
+create  table PCOFGSs(PCOFGS) primary key id;
+
+create  index species  on Ss (Species:string) type btree enforced;
+
+create  index genus  on GSs (lower.Species:string) type btree enforced;
+
+create  index family  on FGSs (lower.lower.Species:string) type btree enforced;
+
+create  index orda  on OFGSs (lower.lower.lower.Species:string) type btree enforced;
+
+create  index classy  on COFGSs (lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on PCOFGSs (lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index phylum  on KPCOFGSs (lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index class  on Classifications (fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
+create  index anim  on Animals (class.fullClassification.lower.lower.lower.lower.lower.lower.Species:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.2.update.sqlpp
new file mode 100644
index 0000000..f5277f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.2.update.sqlpp
@@ -0,0 +1,108 @@
+/*
+ * 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  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+insert into Ss
+select element {'id':1,'Species':'Gulo'};
+insert into Ss
+select element {'id':2,'Species':'Johnstoni'};
+insert into GSs
+select element {'id':1,'Genus':'Gulo','lower':S}
+from  Ss as S
+where (S.Species = 'Gulo')
+;
+insert into GSs
+select element {'id':2,'Genus':'Okapia','lower':S}
+from  Ss as S
+where (S.Species = 'Johnstoni')
+;
+insert into FGSs
+select element {'id':1,'Family':'Mustelinae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Gulo')
+;
+insert into FGSs
+select element {'id':2,'Family':'Giraffidae','lower':S}
+from  GSs as S
+where (S.lower.Species = 'Johnstoni')
+;
+insert into OFGSs
+select element {'id':1,'Order':'Carnivora','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Gulo')
+;
+insert into OFGSs
+select element {'id':2,'Order':'Artiodactyla','lower':S}
+from  FGSs as S
+where (S.lower.lower.Species = 'Johnstoni')
+;
+insert into COFGSs
+select element {'id':1,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Gulo')
+;
+insert into COFGSs
+select element {'id':2,'Class':'Mammalia','lower':S}
+from  OFGSs as S
+where (S.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into PCOFGSs
+select element {'id':1,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into PCOFGSs
+select element {'id':2,'Phylum':'Chordata','lower':S}
+from  COFGSs as S
+where (S.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into KPCOFGSs
+select element {'id':1,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into KPCOFGSs
+select element {'id':2,'Kingdom':'Animalia','lower':S}
+from  PCOFGSs as S
+where (S.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Classifications
+select element {'id':1,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Classifications
+select element {'id':2,'fullClassification':S}
+from  KPCOFGSs as S
+where (S.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
+insert into Animals
+select element {'id':1,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
+insert into Animals
+select element {'id':2,'class':S}
+from  Classifications as S
+where (S.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Johnstoni')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.3.query.sqlpp
new file mode 100644
index 0000000..59c0496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create a highly nested datastructure that uses opened and closed datasets
+
+use test;
+
+
+select element test
+from  Animals as test
+where (test.class.fullClassification.lower.lower.lower.lower.lower.lower.Species = 'Gulo')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp
new file mode 100644
index 0000000..e2b6cb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open enforced index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table CSXtmp(CSXTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp
new file mode 100644
index 0000000..82da40c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp
new file mode 100644
index 0000000..6dedea1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open enforced index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index authors_index  on DBLP (nested.authors:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.sqlpp
new file mode 100644
index 0000000..a50d480
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open enforced index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.nested.id,'bid':b.nested.id,'authors':a.nested.authors}
+from  DBLP as a,
+      CSX as b
+where (a.nested.authors /*+ indexnl */  = b.nested.authors)
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..237c783
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
@@ -0,0 +1,83 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerOpenNestedType as
+{
+  cid : int64,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerNestedType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerNestedType
+}
+
+create type test.CustomerOpenType as
+ closed {
+  nested : CustomerOpenNestedType
+}
+
+create  table Customerstmp(CustomerOpenNestedType) primary key cid;
+
+create  table Customers2tmp(CustomerNestedType) primary key cid;
+
+create  table Customers(CustomerOpenType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..7dea2b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
@@ -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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+where (c.cid < 500)
+;
+insert into Customers
+select element {'nested':{'cid':c.cid,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}}
+from  Customerstmp as c
+where (c.cid >= 500)
+;
+insert into Customers2
+select element {'nested':c}
+from  Customers2tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..b90b899
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (nested.name:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..8ea4c98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.nested.name,b.nested.name)
+where ((ed <= 4) and (a.nested.cid < b.nested.cid))
+order by ed,a.nested.cid,b.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..89512d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,82 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerOpenNestedType as
+{
+  cid : int64,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerNestedType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  nested : CustomerNestedType
+}
+
+create type test.CustomerOpenType as
+ closed {
+  nested : CustomerOpenNestedType
+}
+
+create  table Customerstmp(CustomerOpenNestedType) primary key cid;
+
+create  table Customers2tmp(CustomerNestedType) primary key cid;
+
+create  table Customers(CustomerOpenType) primary key nested.cid;
+
+create  table Customers2(CustomerType) primary key nested.cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..93d79db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element {'nested':c}
+from  Customerstmp as c
+where (c.cid < 500)
+;
+insert into Customers
+select element {'nested':{'cid':c.cid,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}}
+from  Customerstmp as c
+where (c.cid >= 500)
+;
+insert into Customers2
+select element {'nested':c}
+from  Customers2tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..7ba9a95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (nested.name:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..0041e79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.nested.name,b.nested.name) <= 4) and (a.nested.cid < b.nested.cid))
+order by a.nested.cid,b.nested.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..32fdd2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table CSXtmp(CSXTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..aa11aac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..ac8d8f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..12c6c62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a.nested,'brec':b.nested,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+order by jacc,a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..996ac0c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table CSXtmp(CSXTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..25ebe1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..41c42ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..3c82687
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a.nested,'brec':b.nested}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.nested.title,3,false),test."gram-tokens"(b.nested.title,3,false)) >= 0.500000f) and (a.nested.id < b.nested.id))
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
new file mode 100644
index 0000000..a2938f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordOpen
+}
+
+create  table MyData1tmp(MyRecordtmp) primary key id;
+
+create  table MyData2tmp(MyRecordtmp) primary key id;
+
+create  table MyData1(MyRecord) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
new file mode 100644
index 0000000..d9c2f5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
@@ -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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an open enforced RTree index, and we expect the 
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table MyData1tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyData2tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into MyData1
+select element {'nested':c}
+from  MyData1tmp as c
+where (c.id < 10)
+;
+insert into MyData1
+select element {'nested':{'id':c.id,'kwds':c.kwds,'line1':c.line1,'line2':c.line2,'poly1':c.poly1,'poly2':c.poly2,'rec':c.rec,'circle':c.circle}}
+from  MyData1tmp as c
+where (c.id >= 10)
+;
+insert into MyData2
+select element {'nested':c}
+from  MyData2tmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
new file mode 100644
index 0000000..cdd168b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index rtree_index  on MyData1 (nested.point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp
new file mode 100644
index 0000000..c9143f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.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.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an  open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.nested.id,'bid':b.nested.id,'apt':a.nested.point,'bp':b.nested.point}
+from  MyData1 as a,
+      MyData2 as b
+where (test."spatial-intersect"(a.nested.point,b.nested.point) and (a.nested.id != b.nested.id))
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..cd10425
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,75 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table CSXtmp(CSXTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..3efa808
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..05449a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..392af74
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested,'jacc':jacc}
+from  DBLP as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title))
+where ((jacc >= 0.500000f) and (a.nested.id < b.nested.id))
+order by jacc,a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..2f3d635
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXTypetmp as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create type test.CSXType as
+ closed {
+  nested : CSXTypetmp
+}
+
+create  table DBLPtmp(DBLPTypetmp) primary key id;
+
+create  table CSXtmp(CSXTypetmp) primary key id;
+
+create  table DBLP(DBLPType) primary key nested.id;
+
+create  table CSX(CSXType) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..0b072df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..e38a83f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..6ec138a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a.nested,'brec':b.nested}
+from  DBLP as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.nested.title),test."word-tokens"(b.nested.title)) >= 0.500000f) and (a.nested.id < b.nested.id))
+order by a.nested.id,b.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..eb94d7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..90206ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'nested':{'tweetid':c.tweetid,'user':c.user,'sender-location':c."sender-location",'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA}}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..ad8a8fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where (t1.nested.countA /*+ indexnl */  = t2.nested.countB)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..eb94d7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (nested.countB:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..90206ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'nested':{'tweetid':c.tweetid,'user':c.user,'sender-location':c."sender-location",'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA}}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..70eb760
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'count1':t1.nested.countA,'t2info':(
+        select element {'tweetid2':t2.nested.tweetid,'count2':t2.nested.countB}
+        from  TweetMessages as t2
+        where ((t1.nested.countA /*+ indexnl */  = t2.nested.countB) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..7745385
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index msgNgramIx  on TweetMessages (nested."message-text":string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..800cb43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'nested':{'tweetid':c.tweetid,'user':c.user,'sender-location':c."sender-location",'send-time':c."send-time",'referred-topics':c."referred-topics",'countA':c.countA,'countB':c.countB}}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..f5cc294
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use test;
+
+
+select element {'tweet':{'id':t1.tweetid,'topics':t1."message-text"},'similar-tweets':(
+        select element {'id':t2.nested.tweetid,'topics':t2.nested."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1."message-text",t2.nested."message-text",7)
+        where (sim[0] and (t2.nested.tweetid != t1.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessagesTmp as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..02a20b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location":point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..a4bcc2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'nested':{'tweetid':c.tweetid,'user':c.user,'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA,'countB':c.countB}}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..e52aba9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2.nested."sender-location",n)
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..02a20b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageNestedType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create type test.TweetMessageType as
+ closed {
+  nested : TweetMessageNestedType
+}
+
+create  table TweetMessages(TweetMessageType) primary key nested.tweetid;
+
+create  table TweetMessagesTmp(TweetMessageNestedType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages (nested."sender-location":point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..a4bcc2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'nested':c}
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'nested':{'tweetid':c.tweetid,'user':c.user,'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA,'countB':c.countB}}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..f6bd22f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.nested.tweetid,'loc1':t1.nested."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.nested.tweetid,'loc2':t2.nested."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2.nested."sender-location",n) and (t1.nested.tweetid != t2.nested.tweetid))
+        order by t2.nested.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1.nested."sender-location",0.5)
+where (t1.nested.tweetid < test.int64('10'))
+order by t1.nested.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
new file mode 100644
index 0000000..7693a91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
@@ -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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpTmp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.Nested as
+{
+  id : int64,
+  age : int64,
+  dept : string
+}
+
+create type test.Emp as
+ closed {
+  nested : Nested
+}
+
+create  table employeeTmp(EmpTmp) primary key id;
+
+create  table employee(Emp) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
new file mode 100644
index 0000000..ba8da01
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+load  table employeeTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into employee
+select element {'nested':{'id':c.id,'fname':c.fname,'lname':c.lname,'age':c.age,'dept':c.dept}}
+from  employeeTmp as c
+where (c.id <= 1000)
+;
+insert into employee
+select element {'nested':{'id':c.id,'age':c.age,'dept':c.dept}}
+from  employeeTmp as c
+where (c.id > 1000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.sqlpp
new file mode 100644
index 0000000..30b4bd4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+create  index idx_employee_f_l_name  on employee (nested.fname:string,nested.lname:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp
new file mode 100644
index 0000000..a3ed473
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use test;
+
+
+select element l.nested
+from  employee as l
+where ((l.nested.fname > 'Julio') and (l.nested.lname > 'Mattocks') and (l.nested.fname <= 'Micco') and (l.nested.lname < 'Vangieson'))
+order by l.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
new file mode 100644
index 0000000..ce21307
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpTmp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.Nested as
+{
+  id : int64,
+  age : int64,
+  dept : string
+}
+
+create type test.Emp as
+ closed {
+  nested : Nested
+}
+
+create  table employeeTmp(EmpTmp) primary key id;
+
+create  table employee(Emp) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
new file mode 100644
index 0000000..b47ca19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+load  table employeeTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into employee
+select element {'nested':{'id':c.id,'fname':c.fname,'lname':c.lname,'age':c.age,'dept':c.dept}}
+from  employeeTmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp
new file mode 100644
index 0000000..fb2d828
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.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.
+ */
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+create  index idx_employee_f_l_name  on employee (nested.fname:string,nested.lname:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp
new file mode 100644
index 0000000..67128d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use test;
+
+
+select element l.nested
+from  employee as l
+where ((l.nested.fname = 'Julio') and (l.nested.lname = 'Isa'))
+order by l.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
new file mode 100644
index 0000000..0462b71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
@@ -0,0 +1,66 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.Nested as
+{
+  o_orderkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : Nested
+}
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
new file mode 100644
index 0000000..09eaa4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':{'o_orderkey':c.o_orderkey,'o_custkey':c.o_custkey,'o_orderstatus':c.o_orderstatus,'o_totalprice':c.o_totalprice,'o_orderdate':c.o_orderdate,'o_orderpriority':c.o_orderpriority,'o_clerk':c.o_clerk,'o_shippriority':c.o_shippriority,'o_comment':c.o_comment}}
+from  Orderstmp as c
+where (c.o_orderkey <= 4000)
+;
+insert into Orders
+select element {'nested':{'o_orderkey':c.o_orderkey,'o_orderstatus':c.o_orderstatus,'o_totalprice':c.o_totalprice,'o_orderdate':c.o_orderdate,'o_orderpriority':c.o_orderpriority,'o_clerk':c.o_clerk,'o_shippriority':c.o_shippriority,'o_comment':c.o_comment}}
+from  Orderstmp as c
+where (c.o_orderkey > 4000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp
new file mode 100644
index 0000000..4615a44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
new file mode 100644
index 0000000..7b0ea32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey,'o_orderstatus':o.nested.o_orderstatus,'o_orderkey2':o2.nested.o_orderkey,'o_custkey2':o2.nested.o_custkey,'o_orderstatus2':o2.nested.o_orderstatus}
+from  Orders as o,
+      Orders as o2
+where ((o.nested.o_custkey = 20) and (o2.nested.o_custkey = 10) and (o.nested.o_orderstatus < o2.nested.o_orderstatus))
+order by o.nested.o_orderkey,o2.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..e70dcf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp
new file mode 100644
index 0000000..5cfca06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+where (c.id <= 50)
+;
+insert into DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}}
+from  DBLPtmp as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..8f00a22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
new file mode 100644
index 0000000..4ac54d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..3c2893a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPClosedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  table DBLPtmp(DBLPClosedType) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp
new file mode 100644
index 0000000..8ad3ee5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLP
+select element {'nested':x}
+from  "test.DBLPtmp" as x
+where (x.id <= 50)
+;
+insert into test.DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}}
+from  "test.DBLPtmp" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..8f00a22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
new file mode 100644
index 0000000..0ae9ee8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper
+where test."edit-distance-contains"(paper.nested.title,'Multmedia',1)[0]
+order by paper.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
new file mode 100644
index 0000000..cc16f57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp
new file mode 100644
index 0000000..82d5950
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+where (c.id <= 50)
+;
+insert into DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'title':c.title,'misc':c.misc}}
+from  DBLPtmp as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp
new file mode 100644
index 0000000..a550a9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
new file mode 100644
index 0000000..b5c7ee0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
new file mode 100644
index 0000000..3c2893a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPClosedType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  table DBLPtmp(DBLPClosedType) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp
new file mode 100644
index 0000000..8ad3ee5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLP
+select element {'nested':x}
+from  "test.DBLPtmp" as x
+where (x.id <= 50)
+;
+insert into test.DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}}
+from  "test.DBLPtmp" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp
new file mode 100644
index 0000000..8f00a22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
new file mode 100644
index 0000000..a4b4a61
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'id':paper.nested.id,'title':paper.nested.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.nested.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+order by paper.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..cc16f57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..82d5950
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+where (c.id <= 50)
+;
+insert into DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'title':c.title,'misc':c.misc}}
+from  DBLPtmp as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..a550a9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.authors:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..dbdbfe7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+with  ed as test."edit-distance-check"(o.nested.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..e70dcf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..5cfca06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+where (c.id <= 50)
+;
+insert into DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}}
+from  DBLPtmp as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..8f00a22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (nested.title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..ac1af89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.nested.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..e70dcf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp
new file mode 100644
index 0000000..5cfca06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+where (c.id <= 50)
+;
+insert into DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}}
+from  DBLPtmp as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..875b6b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.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;
+
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
new file mode 100644
index 0000000..4ac54d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+where test.contains(o.nested.title,'Multimedia')
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..e70dcf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPTypetmp as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  nested : DBLPOpenType
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPTypetmp) primary key id on group1;
+
+create  table DBLP(DBLPType) primary key nested.id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..5cfca06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into DBLP
+select element {'nested':c}
+from  DBLPtmp as c
+where (c.id <= 50)
+;
+insert into DBLP
+select element {'nested':{'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}}
+from  DBLPtmp as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..875b6b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.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;
+
+
+create  index keyword_index  on DBLP (nested.title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..bb34fa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element o.nested
+from  DBLP as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.nested.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
new file mode 100644
index 0000000..a5c8b31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderOpenType as
+{
+  o_orderkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : OrderOpenType
+}
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp
new file mode 100644
index 0000000..4af2c27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp
new file mode 100644
index 0000000..4615a44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
new file mode 100644
index 0000000..05455bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey}
+from  Orders as o
+where ((o.nested.o_custkey = 40) and (o.nested.o_totalprice > 150000.0))
+order by o.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
new file mode 100644
index 0000000..a5c8b31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderTypetmp as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderOpenType as
+{
+  o_orderkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  nested : OrderOpenType
+}
+
+create  table Orderstmp(OrderTypetmp) primary key o_orderkey;
+
+create  table Orders(OrderType) primary key nested.o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp
new file mode 100644
index 0000000..c7e3d87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orderstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into Orders
+select element {'nested':c}
+from  Orderstmp as c
+where (c.o_orderkey <= 3000)
+;
+insert into Orders
+select element {'nested':{'o_orderkey':c.o_orderkey,'o_orderstatus':c.o_orderstatus,'o_totalprice':c.o_totalprice,'o_orderdate':c.o_orderdate,'o_orderpriority':c.o_orderpriority,'o_clerk':c.o_clerk,'o_shippriority':c.o_shippriority,'o_comment':c.o_comment}}
+from  Orderstmp as c
+where (c.o_orderkey > 3000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp
new file mode 100644
index 0000000..4615a44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on Orders (nested.o_custkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
new file mode 100644
index 0000000..2316399
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.nested.o_orderkey,'o_custkey':o.nested.o_custkey}
+from  Orders as o
+where (o.nested.o_custkey = 40)
+order by o.nested.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.1.ddl.sqlpp
new file mode 100644
index 0000000..7542eb5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.1.ddl.sqlpp
@@ -0,0 +1,73 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemTypetmp as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemOpenType as
+{
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemType as
+ closed {
+  nested : LineItemOpenType
+}
+
+create  table LineItemtmp(LineItemTypetmp) primary key l_orderkey,l_linenumber;
+
+create  table LineItem(LineItemType) primary key nested.l_orderkey,nested.l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.2.update.sqlpp
new file mode 100644
index 0000000..efc2bac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItemtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into LineItem
+select element {'nested':c}
+from  LineItemtmp as c
+where (c.l_orderkey < 3000)
+;
+insert into LineItem
+select element {'nested':{'l_orderkey':x.l_orderkey,'l_partkey':x.l_partkey,'l_linenumber':x.l_linenumber,'l_quantity':x.l_quantity,'l_extendedprice':x.l_extendedprice,'l_discount':x.l_discount,'l_tax':x.l_tax,'l_returnflag':x.l_returnflag,'l_linestatus':x.l_linestatus,'l_shipdate':x.l_shipdate,'l_commitdate':x.l_commitdate,'l_receiptdate':x.l_receiptdate,'l_shipinstruct':x.l_shipinstruct,'l_shipmode':x.l_shipmode,'l_comment':x.l_comment}}
+from  LineItemtmp as x
+where (x.l_orderkey >= 3000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.3.ddl.sqlpp
new file mode 100644
index 0000000..ced3342
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.3.ddl.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;
+
+
+create  index idx_LineItem_suppkey  on LineItem (nested.l_suppkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.4.query.sqlpp
new file mode 100644
index 0000000..37f904b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/range-search/range-search.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c.nested
+from  LineItem as c
+where ((c.nested.l_suppkey < 100) and (c.nested.l_suppkey > 5))
+order by c.nested.l_orderkey,c.nested.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..cc36155
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordtmp as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecord as
+ closed {
+  nested : MyRecordtmp
+}
+
+create  table MyDatatmp(MyRecordtmp) primary key id;
+
+create  table MyData(MyRecord) primary key nested.id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..76f6b71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.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.
+ */
+
+use test;
+
+
+load  table MyDatatmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+insert into MyData
+select element {'nested':c}
+from  MyDatatmp as c
+where (c.id < 15)
+;
+insert into MyData
+select element {'nested':{'id':c.id,'kwds':c.kwds,'line1':c.line1,'line2':c.line2,'poly1':c.poly1,'poly2':c.poly2,'rec':c.rec,'circle':c.circle}}
+from  MyDatatmp as c
+where (c.id >= 15)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..5eaa3f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.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;
+
+
+create  index rtree_index_point  on MyData (nested.point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
new file mode 100644
index 0000000..e72d774
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.nested.id}
+from  MyData as o
+where test."spatial-intersect"(o.nested.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.nested.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.1.ddl.sqlpp
new file mode 100644
index 0000000..a31dbc5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : nestrecord.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.AddressType as
+{
+  street : string,
+  city : string
+}
+
+create type testdv2.testtype as
+{
+  name : string,
+  id : string,
+  address : AddressType?
+}
+
+create  table testds(testtype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.2.update.sqlpp
new file mode 100644
index 0000000..c66d98a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : nestrecord.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+insert into testds
+select element {'id':'001','name':'Person One','address':{'street':'3019 DBH','city':'Irvine','zip':92697}};
+insert into testds
+select element {'id':'002','name':'Person Two'};
+insert into testds
+select element {'id':'003','name':'Person Three','address':{'street':'2019 DBH','city':'Irvine'}};
+insert into testds
+select element {'id':'004','name':'Person Four','home':{'street':'2019 DBH','city':{'name':'Irvine','zip':92697}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.3.query.sqlpp
new file mode 100644
index 0000000..3bd908c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/nestrecords/nestrecord/nestrecord.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : nestrecord.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use testdv2;
+
+
+select element d
+from  testds as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.3.query.sqlpp
new file mode 100644
index 0000000..fdab886
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs0/abs0.3.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;
+
+
+{'f0':test.abs(test.int8('-0')),'f1':test.abs(test.int16('-0')),'f2':test.abs(test.int32('-0')),'f3':test.abs(test.int64('-0')),'f4':test.abs(test.int8('0')),'f5':test.abs(test.int16('0')),'f6':test.abs(test.int32('0')),'f7':test.abs(test.int64('0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.3.query.sqlpp
new file mode 100644
index 0000000..adbf013
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs1/abs1.3.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;
+
+
+{'f0':test.abs(test.int8('-20')),'f1':test.abs(test.int16('-23')),'f2':test.abs(test.int32('-29')),'f3':test.abs(test.int64('-21')),'f4':test.abs(test.int8('20')),'f5':test.abs(test.int16('22')),'f6':test.abs(test.int32('23')),'f7':test.abs(test.int64('27'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.3.query.sqlpp
new file mode 100644
index 0000000..3b3ea2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs2/abs2.3.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;
+
+
+{'f0':test.abs(test.float('-20.1')),'f1':test.abs(test.float('-20.56e-30')),'f2':test.abs(test.float('NaN')),'f3':test.abs(test.float('INF')),'f4':test.abs(test.float('-INF')),'f5':test.abs(test.float('-0.0')),'f6':test.abs(test.float('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.3.query.sqlpp
new file mode 100644
index 0000000..823c3a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs3/abs3.3.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;
+
+
+{'d0':test.abs(test.double('-20.1')),'d1':test.abs(test.double('-20.56e-30')),'d2':test.abs(test.double('NaN')),'d3':test.abs(test.double('INF')),'d4':test.abs(test.double('-INF')),'d5':test.abs(test.double('-0.0')),'d6':test.abs(test.double('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.3.query.sqlpp
new file mode 100644
index 0000000..7b6a00e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/abs4/abs4.3.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;
+
+
+{'f0':test.abs(test.int8('-20')),'f1':test.abs(-1.11),'f2':test.abs(12.9),'f3':test.abs(1.11)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.3.query.sqlpp
new file mode 100644
index 0000000..6af577d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_double/add_double.3.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;
+
+
+{'result1':(test.double('-6.5d') + test.int8('+1')),'result2':(test.double('-6.5d') + test.int16('2')),'result3':(test.double('-6.5d') + test.int32('+3')),'result4':(test.double('-6.5d') + test.int64('-4')),'result5':(test.double('-6.5d') + test.float('-5.5f')),'result6':(test.double('-6.5d') + test.double('-6.5d')),'result7':(test.double('-6.5d') + [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.3.query.sqlpp
new file mode 100644
index 0000000..5c7f3cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_float/add_float.3.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;
+
+
+{'result1':(test.float('-5.5f') + test.int8('+1')),'result2':(test.float('-5.5f') + test.int16('2')),'result3':(test.float('-5.5f') + test.int32('+3')),'result4':(test.float('-5.5f') + test.int64('-4')),'result5':(test.float('-5.5f') + test.float('-5.5f')),'result6':(test.float('-5.5f') + test.double('-6.5d')),'result7':(test.double('-6.5d') + [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.3.query.sqlpp
new file mode 100644
index 0000000..6e4fec1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int16/add_int16.3.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;
+
+
+{'result1':(test.int16('2') + test.int8('+1')),'result2':(test.int16('2') + test.int16('2')),'result3':(test.int16('2') + test.int32('+3')),'result4':(test.int16('2') + test.int64('-4')),'result5':(test.int16('2') + test.float('-5.5f')),'result6':(test.int16('2') + test.double('-6.5d')),'result7':(test.double('-6.5d') + [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.3.query.sqlpp
new file mode 100644
index 0000000..c168f6d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int32/add_int32.3.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;
+
+
+{'result1':(test.int32('+3') + test.int8('+1')),'result2':(test.int32('+3') + test.int16('2')),'result3':(test.int32('+3') + test.int32('+3')),'result4':(test.int32('+3') + test.int64('-4')),'result5':(test.int32('+3') + test.float('-5.5f')),'result6':(test.int32('+3') + test.double('-6.5d')),'result7':(test.double('-6.5d') + [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.3.query.sqlpp
new file mode 100644
index 0000000..57d0b16
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int64/add_int64.3.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;
+
+
+{'result1':(test.int64('-4') + test.int8('+1')),'result2':(test.int64('-4') + test.int16('2')),'result3':(test.int64('-4') + test.int32('+3')),'result4':(test.int64('-4') + test.int64('-4')),'result5':(test.int64('-4') + test.float('-5.5f')),'result6':(test.int64('-4') + test.double('-6.5d')),'result7':(test.double('-6.5d') + [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.3.query.sqlpp
new file mode 100644
index 0000000..16c74e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/add_int8/add_int8.3.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;
+
+
+{'result1':(test.int8('+1') + test.int8('+1')),'result2':(test.int8('+1') + test.int16('2')),'result3':(test.int8('+1') + test.int32('+3')),'result4':(test.int8('+1') + test.int64('-4')),'result5':(test.int8('+1') + test.float('-5.5f')),'result6':(test.int8('+1') + test.double('-6.5d')),'result7':(test.double('-6.5d') + [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.3.query.sqlpp
new file mode 100644
index 0000000..d709673
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/caret0/caret0.3.query.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.
+ */
+
+{'c1':(2.0 ^ 4096.0),'c2':(4096.0 ^ 2.0),'c3':(3 ^ 2)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.3.query.sqlpp
new file mode 100644
index 0000000..b4361e6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling0/ceiling0.3.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;
+
+
+{'f0':test.ceiling(test.int8('-0')),'f1':test.ceiling(test.int16('-0')),'f2':test.ceiling(test.int32('-0')),'f3':test.ceiling(test.int64('-0')),'f4':test.ceiling(test.int8('0')),'f5':test.ceiling(test.int16('0')),'f6':test.ceiling(test.int32('0')),'f7':test.ceiling(test.int64('0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.3.query.sqlpp
new file mode 100644
index 0000000..06282e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling1/ceiling1.3.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;
+
+
+{'f0':test.ceiling(test.int8('-20')),'f1':test.ceiling(test.int16('-23')),'f2':test.ceiling(test.int32('-29')),'f3':test.ceiling(test.int64('-21')),'f4':test.ceiling(test.int8('20')),'f5':test.ceiling(test.int16('22')),'f6':test.ceiling(test.int32('23')),'f7':test.ceiling(test.int64('27'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.3.query.sqlpp
new file mode 100644
index 0000000..18df748
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling2/ceiling2.3.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;
+
+
+{'f0':test.ceiling(test.float('20.1')),'f1':test.ceiling(test.float('-20.56e-30')),'f2':test.ceiling(test.float('NaN')),'f3':test.ceiling(test.float('INF')),'f4':test.ceiling(test.float('-INF')),'f5':test.ceiling(test.float('-0.0')),'f6':test.ceiling(test.float('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.3.query.sqlpp
new file mode 100644
index 0000000..e3ef656
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling3/ceiling3.3.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;
+
+
+{'d0':test.ceiling(test.double('20.1')),'d1':test.ceiling(test.double('-20.56e-30')),'d2':test.ceiling(test.double('NaN')),'d3':test.ceiling(test.double('INF')),'d4':test.ceiling(test.double('-INF')),'d5':test.ceiling(test.double('-0.0')),'d6':test.ceiling(test.double('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.3.query.sqlpp
new file mode 100644
index 0000000..6447632
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ceiling4/ceiling4.3.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;
+
+
+{'f0':test.ceiling(test.int8('-20')),'f1':test.ceiling(-1.11),'f2':test.ceiling(12.9),'f3':test.ceiling(1.11)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.3.query.sqlpp
new file mode 100644
index 0000000..aa02d10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_double/divide_double.3.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;
+
+
+{'result1':(test.double('-6.5d') / test.int8('+1')),'result2':(test.double('-6.5d') / test.int16('2')),'result3':(test.double('-6.5d') / test.int32('+3')),'result4':(test.double('-6.5d') / test.int64('-4')),'result5':(test.double('-6.5d') / test.float('-5.5f')),'result6':(test.double('-6.5d') / test.double('-6.5d')),'result7':(test.double('-6.5d') / [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.3.query.sqlpp
new file mode 100644
index 0000000..1b9773d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_float/divide_float.3.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;
+
+
+{'result1':(test.float('-5.5f') / test.int8('+1')),'result2':(test.float('-5.5f') / test.int16('2')),'result3':(test.float('-5.5f') / test.int32('+3')),'result4':(test.float('-5.5f') / test.int64('-4')),'result5':(test.float('-5.5f') / test.float('-5.5f')),'result6':(test.float('-5.5f') / test.double('-6.5d')),'result7':(test.double('-6.5d') / [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.3.query.sqlpp
new file mode 100644
index 0000000..7910160
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int16/divide_int16.3.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;
+
+
+{'result1':(test.int16('2') / test.int8('+1')),'result2':(test.int16('2') / test.int16('2')),'result3':(test.int16('2') / test.int32('+3')),'result4':(test.int16('2') / test.int64('-4')),'result5':(test.int16('2') / test.float('-5.5f')),'result6':(test.int16('2') / test.double('-6.5d')),'result7':(test.double('-6.5d') / [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.3.query.sqlpp
new file mode 100644
index 0000000..4b3e4e2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int32/divide_int32.3.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;
+
+
+{'result1':(test.int32('+3') / test.int8('+1')),'result2':(test.int32('+3') / test.int16('2')),'result3':(test.int32('+3') / test.int32('+3')),'result4':(test.int32('+3') / test.int64('-4')),'result5':(test.int32('+3') / test.float('-5.5f')),'result6':(test.int32('+3') / test.double('-6.5d')),'result7':(test.double('-6.5d') / [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.3.query.sqlpp
new file mode 100644
index 0000000..3e93c31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int64/divide_int64.3.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;
+
+
+{'result1':(test.int64('-4') / test.int8('+1')),'result2':(test.int64('-4') / test.int16('2')),'result3':(test.int64('-4') / test.int32('+3')),'result4':(test.int64('-4') / test.int64('-4')),'result5':(test.int64('-4') / test.float('-5.5f')),'result6':(test.int64('-4') / test.double('-6.5d')),'result7':(test.double('-6.5d') / [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.3.query.sqlpp
new file mode 100644
index 0000000..0824b80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/divide_int8/divide_int8.3.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;
+
+
+{'result1':(test.int8('+1') / test.int8('+1')),'result2':(test.int8('+1') / test.int16('2')),'result3':(test.int8('+1') / test.int32('+3')),'result4':(test.int8('+1') / test.int64('-4')),'result5':(test.int8('+1') / test.float('-5.5f')),'result6':(test.int8('+1') / test.double('-6.5d')),'result7':(test.double('-6.5d') / [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.3.query.sqlpp
new file mode 100644
index 0000000..9f34df9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor0/floor0.3.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;
+
+
+{'f0':test.floor(test.int8('-0')),'f1':test.floor(test.int16('-0')),'f2':test.floor(test.int32('-0')),'f3':test.floor(test.int64('-0')),'f4':test.floor(test.int8('0')),'f5':test.floor(test.int16('0')),'f6':test.floor(test.int32('0')),'f7':test.floor(test.int64('0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.3.query.sqlpp
new file mode 100644
index 0000000..7935c03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor1/floor1.3.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;
+
+
+{'f0':test.floor(test.int8('-20')),'f1':test.floor(test.int16('-23')),'f2':test.floor(test.int32('-29')),'f3':test.floor(test.int64('-21')),'f4':test.floor(test.int8('20')),'f5':test.floor(test.int16('22')),'f6':test.floor(test.int32('23')),'f7':test.floor(test.int64('27'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.3.query.sqlpp
new file mode 100644
index 0000000..9ca4560
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor2/floor2.3.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;
+
+
+{'f0':test.floor(test.float('20.1')),'f1':test.floor(test.float('-20.56e-30')),'f2':test.floor(test.float('NaN')),'f3':test.floor(test.float('INF')),'f4':test.floor(test.float('-INF')),'f5':test.floor(test.float('-0.0')),'f6':test.floor(test.float('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.3.query.sqlpp
new file mode 100644
index 0000000..5a9c31f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor3/floor3.3.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;
+
+
+{'d0':test.floor(test.double('20.1')),'d1':test.floor(test.double('-20.56e-30')),'d2':test.floor(test.double('NaN')),'d3':test.floor(test.double('INF')),'d4':test.floor(test.double('-INF')),'d5':test.floor(test.double('-0.0')),'d6':test.floor(test.double('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.3.query.sqlpp
new file mode 100644
index 0000000..5de8f2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/floor4/floor4.3.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;
+
+
+{'f0':test.floor(test.int8('-20')),'f1':test.floor(-1.11),'f2':test.floor(12.9),'f3':test.floor(1.11)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.3.query.sqlpp
new file mode 100644
index 0000000..b515443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_double/multiply_double.3.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;
+
+
+{'result1':(test.double('-6.5d') * test.int8('+1')),'result2':(test.double('-6.5d') * test.int16('2')),'result3':(test.double('-6.5d') * test.int32('+3')),'result4':(test.double('-6.5d') * test.int64('-4')),'result5':(test.double('-6.5d') * test.float('-5.5f')),'result6':(test.double('-6.5d') * test.double('-6.5d')),'result7':(test.double('-6.5d') * [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.3.query.sqlpp
new file mode 100644
index 0000000..237f033
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_float/multiply_float.3.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;
+
+
+{'result1':(test.float('-5.5f') * test.int8('+1')),'result2':(test.float('-5.5f') * test.int16('2')),'result3':(test.float('-5.5f') * test.int32('+3')),'result4':(test.float('-5.5f') * test.int64('-4')),'result5':(test.float('-5.5f') * test.float('-5.5f')),'result6':(test.float('-5.5f') * test.double('-6.5d')),'result7':(test.double('-6.5d') * [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.3.query.sqlpp
new file mode 100644
index 0000000..06d91aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int16/multiply_int16.3.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;
+
+
+{'result1':(test.int16('2') * test.int8('+1')),'result2':(test.int16('2') * test.int16('2')),'result3':(test.int16('2') * test.int32('+3')),'result4':(test.int16('2') * test.int64('-4')),'result5':(test.int16('2') * test.float('-5.5f')),'result6':(test.int16('2') * test.double('-6.5d')),'result7':(test.double('-6.5d') * [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.3.query.sqlpp
new file mode 100644
index 0000000..55f5ffc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int32/multiply_int32.3.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;
+
+
+{'result1':(test.int32('+3') * test.int8('+1')),'result2':(test.int32('+3') * test.int16('2')),'result3':(test.int32('+3') * test.int32('+3')),'result4':(test.int32('+3') * test.int64('-4')),'result5':(test.int32('+3') * test.float('-5.5f')),'result6':(test.int32('+3') * test.double('-6.5d')),'result7':(test.double('-6.5d') * [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.3.query.sqlpp
new file mode 100644
index 0000000..84aaf95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int64/multiply_int64.3.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;
+
+
+{'result1':(test.int64('-4') * test.int8('+1')),'result2':(test.int64('-4') * test.int16('2')),'result3':(test.int64('-4') * test.int32('+3')),'result4':(test.int64('-4') * test.int64('-4')),'result5':(test.int64('-4') * test.float('-5.5f')),'result6':(test.int64('-4') * test.double('-6.5d')),'result7':(test.double('-6.5d') * [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.3.query.sqlpp
new file mode 100644
index 0000000..eb573e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/multiply_int8/multiply_int8.3.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;
+
+
+{'result1':(test.int8('+1') * test.int8('+1')),'result2':(test.int8('+1') * test.int16('2')),'result3':(test.int8('+1') * test.int32('+3')),'result4':(test.int8('+1') * test.int64('-4')),'result5':(test.int8('+1') * test.float('-5.5f')),'result6':(test.int8('+1') * test.double('-6.5d')),'result7':(test.double('-6.5d') * [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.3.query.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-issue355/query-issue355.3.query.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.3.query.sqlpp
new file mode 100644
index 0000000..891e264
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even0/round-half-to-even0.3.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;
+
+
+{'f0':test."round-half-to-even"(test.int8('-0')),'f1':test."round-half-to-even"(test.int16('-0')),'f2':test."round-half-to-even"(test.int32('-0')),'f3':test."round-half-to-even"(test.int64('-0')),'f4':test."round-half-to-even"(test.int8('0')),'f5':test."round-half-to-even"(test.int16('0')),'f6':test."round-half-to-even"(test.int32('0')),'f7':test."round-half-to-even"(test.int64('0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.3.query.sqlpp
new file mode 100644
index 0000000..c8ec1e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even1/round-half-to-even1.3.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;
+
+
+{'f0':test."round-half-to-even"(test.int8('-20')),'f1':test."round-half-to-even"(test.int16('-23')),'f2':test."round-half-to-even"(test.int32('-29')),'f3':test."round-half-to-even"(test.int64('-21')),'f4':test."round-half-to-even"(test.int8('20')),'f5':test."round-half-to-even"(test.int16('22')),'f6':test."round-half-to-even"(test.int32('23')),'f7':test."round-half-to-even"(test.int64('27'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.3.query.sqlpp
new file mode 100644
index 0000000..aaae70d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even2/round-half-to-even2.3.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;
+
+
+{'f0':test."round-half-to-even"(test.float('0.5')),'f1':test."round-half-to-even"(test.float('-20.5')),'f2':test."round-half-to-even"(test.float('NaN')),'f3':test."round-half-to-even"(test.float('INF')),'f4':test."round-half-to-even"(test.float('-INF')),'f5':test."round-half-to-even"(test.float('-0.0')),'f6':test."round-half-to-even"(test.float('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.3.query.sqlpp
new file mode 100644
index 0000000..a1b5423
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even20/round-half-to-even20.3.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;
+
+
+{'f0':test."round-half-to-even"(test.int8('-0'),2),'f1':test."round-half-to-even"(test.int16('-0'),2),'f2':test."round-half-to-even"(test.int32('-0'),2),'f3':test."round-half-to-even"(test.int64('-0'),2),'f4':test."round-half-to-even"(test.int8('0'),2),'f5':test."round-half-to-even"(test.int16('0'),2),'f6':test."round-half-to-even"(test.int32('0'),2),'f7':test."round-half-to-even"(test.int64('0'),2)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.3.query.sqlpp
new file mode 100644
index 0000000..1747df2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even21/round-half-to-even21.3.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;
+
+
+{'f0':test."round-half-to-even"(test.int8('-20'),2),'f1':test."round-half-to-even"(test.int16('-23'),2),'f2':test."round-half-to-even"(test.int32('-29'),2),'f3':test."round-half-to-even"(test.int64('-21'),2),'f4':test."round-half-to-even"(test.int8('20'),2),'f5':test."round-half-to-even"(test.int16('22'),2),'f6':test."round-half-to-even"(test.int32('23'),2),'f7':test."round-half-to-even"(test.int64('27'),2)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.3.query.sqlpp
new file mode 100644
index 0000000..9988f98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even22/round-half-to-even22.3.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;
+
+
+{'d0':test."round-half-to-even"(test.float('0.555'),2),'d1':test."round-half-to-even"(test.float('0.322'),2),'d2':test."round-half-to-even"(test.float('NaN'),3),'d3':test."round-half-to-even"(test.float('INF'),4),'d4':test."round-half-to-even"(test.float('-INF'),5),'d5':test."round-half-to-even"(test.float('-0.0'),6),'d6':test."round-half-to-even"(test.float('0.0'),0)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.3.query.sqlpp
new file mode 100644
index 0000000..8e4fd13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even23/round-half-to-even23.3.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;
+
+
+{'d0':test."round-half-to-even"(test.double('0.555'),2),'d1':test."round-half-to-even"(test.double('0.322'),2),'d2':test."round-half-to-even"(test.double('NaN'),3),'d3':test."round-half-to-even"(test.double('INF'),4),'d4':test."round-half-to-even"(test.double('-INF'),5),'d5':test."round-half-to-even"(test.double('-0.0'),6),'d6':test."round-half-to-even"(test.double('0.0'),0)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.query.sqlpp
new file mode 100644
index 0000000..5f11656
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.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;
+
+
+{'d0':test."round-half-to-even"(test.double('0.015'),2),'d1':test."round-half-to-even"(test.double('0.025'),2),'d2':test."round-half-to-even"(test.double('3.567812E+3'),2),'d3':test."round-half-to-even"(test.double('4.7564E-3'),2),'d4':test."round-half-to-even"(test.double('35612.25'),-2)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.3.query.sqlpp
new file mode 100644
index 0000000..7b629c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even3/round-half-to-even3.3.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;
+
+
+{'d0':test."round-half-to-even"(test.double('0.5')),'d1':test."round-half-to-even"(test.double('-20.5')),'d2':test."round-half-to-even"(test.double('NaN')),'d3':test."round-half-to-even"(test.double('INF')),'d4':test."round-half-to-even"(test.double('-INF')),'d5':test."round-half-to-even"(test.double('-0.0')),'d6':test."round-half-to-even"(test.double('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.3.query.sqlpp
new file mode 100644
index 0000000..ba845c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even4/round-half-to-even4.3.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;
+
+
+{'d0':test."round-half-to-even"(test.double('1.5')),'d1':test."round-half-to-even"(test.double('2.5'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.query.sqlpp
new file mode 100644
index 0000000..c180f9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.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;
+
+
+{'f0':test."round-half-to-even"(test.int8('-20')),'f1':test."round-half-to-even"(-1.5),'f2':test."round-half-to-even"(12.5),'f3':test."round-half-to-even"(1.5)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.3.query.sqlpp
new file mode 100644
index 0000000..3f7b8f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round0/round0.3.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;
+
+
+{'f0':test.round(test.int8('-0')),'f1':test.round(test.int16('-0')),'f2':test.round(test.int32('-0')),'f3':test.round(test.int64('-0')),'f4':test.round(test.int8('0')),'f5':test.round(test.int16('0')),'f6':test.round(test.int32('0')),'f7':test.round(test.int64('0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.3.query.sqlpp
new file mode 100644
index 0000000..baa8910
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round1/round1.3.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;
+
+
+{'f0':test.round(test.int8('-20')),'f1':test.round(test.int16('-23')),'f2':test.round(test.int32('-29')),'f3':test.round(test.int64('-21')),'f4':test.round(test.int8('20')),'f5':test.round(test.int16('22')),'f6':test.round(test.int32('23')),'f7':test.round(test.int64('27'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.3.query.sqlpp
new file mode 100644
index 0000000..ef3609d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round2/round2.3.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;
+
+
+{'f0':test.round(test.float('20.1')),'f1':test.round(test.float('-20.56e-30')),'f2':test.round(test.float('NaN')),'f3':test.round(test.float('INF')),'f4':test.round(test.float('-INF')),'f5':test.round(test.float('-0.0')),'f6':test.round(test.float('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.3.query.sqlpp
new file mode 100644
index 0000000..2893a13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round3/round3.3.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;
+
+
+{'d0':test.round(test.double('20.1')),'d1':test.round(test.double('-20.56e-30')),'d2':test.round(test.double('NaN')),'d3':test.round(test.double('INF')),'d4':test.round(test.double('-INF')),'d5':test.round(test.double('-0.0')),'d6':test.round(test.double('0.0'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.3.query.sqlpp
new file mode 100644
index 0000000..3abcdfc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/round4/round4.3.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;
+
+
+{'f0':test.round(test.int8('-20')),'f1':test.round(-1.11),'f2':test.round(12.9),'f3':test.round(1.11)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.3.query.sqlpp
new file mode 100644
index 0000000..3ed6d8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_double/subtract_double.3.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;
+
+
+{'result1':(test.double('-6.5d') - test.int8('+1')),'result2':(test.double('-6.5d') - test.int16('2')),'result3':(test.double('-6.5d') - test.int32('+3')),'result4':(test.double('-6.5d') - test.int64('-4')),'result5':(test.double('-6.5d') - test.float('-5.5f')),'result6':(test.double('-6.5d') - test.double('-6.5d')),'result7':(test.double('-6.5d') - [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.3.query.sqlpp
new file mode 100644
index 0000000..190d46c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_float/subtract_float.3.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;
+
+
+{'result1':(test.float('-5.5f') - test.int8('+1')),'result2':(test.float('-5.5f') - test.int16('2')),'result3':(test.float('-5.5f') - test.int32('+3')),'result4':(test.float('-5.5f') - test.int64('-4')),'result5':(test.float('-5.5f') - test.float('-5.5f')),'result6':(test.float('-5.5f') - test.double('-6.5d')),'result7':(test.double('-6.5d') - [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.3.query.sqlpp
new file mode 100644
index 0000000..077aa51
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int16/subtract_int16.3.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;
+
+
+{'result1':(test.int16('2') - test.int8('+1')),'result2':(test.int16('2') - test.int16('2')),'result3':(test.int16('2') - test.int32('+3')),'result4':(test.int16('2') - test.int64('-4')),'result5':(test.int16('2') - test.float('-5.5f')),'result6':(test.int16('2') - test.double('-6.5d')),'result7':(test.double('-6.5d') - [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.3.query.sqlpp
new file mode 100644
index 0000000..e1bfde0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int32/subtract_int32.3.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;
+
+
+{'result1':(test.int32('+3') - test.int8('+1')),'result2':(test.int32('+3') - test.int16('2')),'result3':(test.int32('+3') - test.int32('+3')),'result4':(test.int32('+3') - test.int64('-4')),'result5':(test.int32('+3') - test.float('-5.5f')),'result6':(test.int32('+3') - test.double('-6.5d')),'result7':(test.double('-6.5d') - [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.3.query.sqlpp
new file mode 100644
index 0000000..e1ccab4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int64/subtract_int64.3.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;
+
+
+{'result1':(test.int64('-4') - test.int8('+1')),'result2':(test.int64('-4') - test.int16('2')),'result3':(test.int64('-4') - test.int32('+3')),'result4':(test.int64('-4') - test.int64('-4')),'result5':(test.int64('-4') - test.float('-5.5f')),'result6':(test.int64('-4') - test.double('-6.5d')),'result7':(test.double('-6.5d') - [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.3.query.sqlpp
new file mode 100644
index 0000000..fe59795
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/subtract_int8/subtract_int8.3.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;
+
+
+{'result1':(test.int8('+1') - test.int8('+1')),'result2':(test.int8('+1') - test.int16('2')),'result3':(test.int8('+1') - test.int32('+3')),'result4':(test.int8('+1') - test.int64('-4')),'result5':(test.int8('+1') - test.float('-5.5f')),'result6':(test.int8('+1') - test.double('-6.5d')),'result7':(test.double('-6.5d') - [1][1])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.query.sqlpp
new file mode 100644
index 0000000..e1e22fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.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;
+
+
+{'double1':-test.double('-20.56e-30'),'double2':-test.double('NaN'),'double3':-test.double('INF'),'double4':-test.double('-INF')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.query.sqlpp
new file mode 100644
index 0000000..265a63f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.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;
+
+
+{'float1':-test.float('-80.20f'),'float2':-test.float('NaN'),'float3':-test.float('INF'),'float4':-test.float('-INF')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.query.sqlpp
new file mode 100644
index 0000000..f8cca3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.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;
+
+
+{'int8':-test.int8('+80'),'int16':-test.int16('160'),'int32':-test.int32('+320'),'int64':-test.int64('-640')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.3.query.sqlpp
new file mode 100644
index 0000000..38370ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/unary-minus_null/unary-minus_null.3.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;
+
+
+{'nullField':-[1][1]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.1.ddl.sqlpp
new file mode 100644
index 0000000..09e472c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : c2c-w-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  description : string,
+  name : string,
+  optnl_fld : string?
+}
+
+create  table T1(TestType) primary key id;
+
+create  table T2(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.2.update.sqlpp
new file mode 100644
index 0000000..86752eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : c2c-w-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake','optnl_fld':'optional data goes here'};
+insert into T2
+select element l
+from  T1 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.3.query.sqlpp
new file mode 100644
index 0000000..9093ec5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-w-optional/c2c-w-option.3.query.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.
+ */
+/*
+ * Testcase Name  : c2c-w-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+use test;
+
+
+select element d
+from  T2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.1.ddl.sqlpp
new file mode 100644
index 0000000..5fb0d33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.1.ddl.sqlpp
@@ -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.
+ */
+/*
+ * Testcase Name  : c2c-wo-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ *                : Note that the optional field in source dataset does not hold any data.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  description : string,
+  name : string,
+  optnl_fld : string?
+}
+
+create  table T1(TestType) primary key id;
+
+create  table T2(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.2.update.sqlpp
new file mode 100644
index 0000000..de5496d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.2.update.sqlpp
@@ -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.
+ */
+/*
+ * Testcase Name  : c2c-wo-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ *                : Note that the optional field in source dataset does not hold any data.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake'};
+insert into T2
+select element l
+from  T1 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.3.query.sqlpp
new file mode 100644
index 0000000..bdc5ba5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c-wo-optional/c2c-wo-optional.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : c2c-wo-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ *                : Note that the optional field in source dataset does not hold any data.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+use test;
+
+
+select element d
+from  T2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.1.ddl.sqlpp
new file mode 100644
index 0000000..648baf5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : c2c.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+ closed {
+  id : int32,
+  description : string,
+  name : string
+}
+
+create  table T1(TestType) primary key id;
+
+create  table T2(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.2.update.sqlpp
new file mode 100644
index 0000000..dd66d9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : c2c.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake'};
+insert into T2
+select element l
+from  T1 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.3.query.sqlpp
new file mode 100644
index 0000000..07b7443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/c2c/c2c.3.query.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.
+ */
+/*
+ * Testcase Name  : c2c.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+use test;
+
+
+select element d
+from  T2 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.1.ddl.sqlpp
new file mode 100644
index 0000000..092003e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : heterog-list01.aql
+ * Description    : To test insertion of an array of objects into internal dataset.
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 14th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.BatterType as
+{
+  id : int64,
+  descrpt : string
+}
+
+create type test.TestType as
+ closed {
+  id : int64,
+  description : string,
+  name : string,
+  batters : [[BatterType]]
+}
+
+create  table T1(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.2.update.sqlpp
new file mode 100644
index 0000000..1cb1bb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name : heterog-list01.aql
+ * Description    : To test insertion of an array of objects into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 14th April 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake','batters':[[{'id':345,'descrpt':'Regular'},{'id':445,'descrpt':'Chocolate'}]]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.3.query.sqlpp
new file mode 100644
index 0000000..7c8f5fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.3.query.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.
+ */
+/*
+ * Test case Name : heterog-list01.aql
+ * Description    : To test insertion of an array of objects into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 14th April 2012
+ */
+
+use test;
+
+
+select element d
+from  T1 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.1.ddl.sqlpp
new file mode 100644
index 0000000..91cb304
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : heterog-list01.aql
+ * Description    : To test insertion of an array of objects into internal dataset.
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 14th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.BatterType as
+{
+  id : int64,
+  descrpt : string
+}
+
+create type test.TestType as
+ closed {
+  id : int64,
+  description : string,
+  name : string,
+  batters : {{BatterType}}
+}
+
+create  table T1(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.2.update.sqlpp
new file mode 100644
index 0000000..a6adfa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name : heterog-list01.aql
+ * Description    : To test insertion of an array of objects into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 14th April 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake','batters':{{{'id':345,'descrpt':'Regular'},{'id':445,'descrpt':'Chocolate'}}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.3.query.sqlpp
new file mode 100644
index 0000000..7c8f5fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list01/heterog-list01.3.query.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.
+ */
+/*
+ * Test case Name : heterog-list01.aql
+ * Description    : To test insertion of an array of objects into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 14th April 2012
+ */
+
+use test;
+
+
+select element d
+from  T1 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.1.ddl.sqlpp
new file mode 100644
index 0000000..50b7ddf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : heterog-list02.aql
+ * Description    : To test insertion of an array of arrays into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 28th May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.BatterType as
+{
+  id : int32,
+  descrpt : string
+}
+
+create type test.TestType as
+{
+  id : int32,
+  description : string,
+  name : string,
+  batters : [[BatterType]]
+}
+
+create  table T1(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.2.update.sqlpp
new file mode 100644
index 0000000..b6fa3f2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name : heterog-list02.aql
+ * Description    : To test insertion of an array of arrays into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 28th May 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake','batters':[[{'id':345,'descrpt':'Regular'},{'id':445,'descrpt':'Chocolate'}],[{'id':349,'descrpt':'Soft'},{'id':449,'descrpt':'Vanilla'}]]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.3.query.sqlpp
new file mode 100644
index 0000000..2c2ba4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list02/heterog-list02.3.query.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.
+ */
+/*
+ * Test case Name : heterog-list02.aql
+ * Description    : To test insertion of an array of arrays into internal dataset. 
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 28th May 2012
+ */
+
+use test;
+
+
+select element l
+from  T1 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.1.ddl.sqlpp
new file mode 100644
index 0000000..aad4c08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : heterog-list03.aql
+ * Description    : To test insertion of an array of arrays into internal dataset. 
+ *                : batters field is optional in this scenario.
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 28th May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.BatterType as
+{
+  id : int32,
+  descrpt : string
+}
+
+create type test.TestType as
+{
+  id : int32,
+  description : string,
+  name : string,
+  batters : [[BatterType]]?
+}
+
+create  table T1(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.2.update.sqlpp
new file mode 100644
index 0000000..7962aec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.2.update.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.
+ */
+/*
+ * Test case Name : heterog-list03.aql
+ * Description    : To test insertion of an array of arrays into internal dataset. 
+ *                : batters field is optional in this scenario.
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 28th May 2012
+ */
+
+use test;
+
+
+insert into T1
+select element {'id':1234,'description':'donut','name':'Cake','batters':[[{'id':345,'descrpt':'Regular'},{'id':445,'descrpt':'Chocolate'}],[{'id':349,'descrpt':'Soft'},{'id':449,'descrpt':'Vanilla'}]]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.3.query.sqlpp
new file mode 100644
index 0000000..54b03f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/heterog-list03/heterog-list03.3.query.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.
+ */
+/*
+ * Test case Name : heterog-list03.aql
+ * Description    : To test insertion of an array of arrays into internal dataset. 
+ *                : batters field is optional in this scenario.
+ *                : Heterogenous list construction.
+ * Success        : Yes
+ * Date           : 28th May 2012
+ */
+
+use test;
+
+
+select element l
+from  T1 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.1.ddl.sqlpp
new file mode 100644
index 0000000..de7bdd2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.1.ddl.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.
+ */
+/*
+ * Test case Name  : open-closed-01.aql
+ * Description     : This test is intended to test insertion of additional data into an open type
+ * Expected Result : Success
+ * Date            : April 2 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int64,
+  name : string
+}
+
+create  table testds(testType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.2.update.sqlpp
new file mode 100644
index 0000000..c586545
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.2.update.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.
+ */
+/* 
+ * Test case Name  : open-closed-01.aql
+ * Description     : This test is intended to test insertion of additional data into an open type 
+ * Expected Result : Success
+ * Date            : April 2 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':123,'name':'John Doe','hobbies':{{'scuba','music'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.3.query.sqlpp
new file mode 100644
index 0000000..618b04a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-01/open-closed-01.3.query.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.
+ */
+/* 
+ * Test case Name  : open-closed-01.aql
+ * Description     : This test is intended to test insertion of additional data into an open type 
+ * Expected Result : Success
+ * Date            : April 2 2012
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.1.ddl.sqlpp
new file mode 100644
index 0000000..9bb8707
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name : open-closed-12.aql
+ * Description    : Select from dataset two and insert into dataset one, both datasets are of open type.
+ *                : In this case, both datasets are of same schema
+ * Success        : Yes
+ * Date           : 27 March 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string,
+  name : string
+}
+
+create type testdv2.testtype02 as
+{
+  id : string,
+  name : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.2.update.sqlpp
new file mode 100644
index 0000000..35cfb26
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.2.update.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.
+ */
+/*
+ * Test case name : open-closed-12.aql
+ * Description    : Select from dataset two and insert into dataset one, both datasets are of open type.
+ *                : In this case, both datasets are of same schema
+ * Success        : Yes
+ * Date           : 27 March 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'001','name':'Person One','hobbies':{{'scuba','music'}}};
+insert into testds02
+select element {'id':'002','name':'Person Two','hobbies':{{'fishing','dance'}}};
+insert into testds02
+select element {'id':'003','name':'Person Three','hobbies':{{'hiking','surfing'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.3.query.sqlpp
new file mode 100644
index 0000000..d8cf565
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-12/open-closed-12.3.query.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.
+ */
+/*
+ * Test case name : open-closed-12.aql
+ * Description    : Select from dataset two and insert into dataset one, both datasets are of open type.
+ *                : In this case, both datasets are of same schema
+ * Success        : Yes
+ * Date           : 27 March 2012
+ */
+
+use testdv2;
+
+
+select element d
+from  testds01 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.1.ddl.sqlpp
new file mode 100644
index 0000000..e57877e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.1.ddl.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.
+ */
+/*
+ * Testcase name : open-closed-14.aql
+ * Description   : insert into target dataset - select * from source dataset
+ *               : in this case dataset1 and dataset2 are fo different schema.
+ * Success       : This test should succeed.
+ * Date          : March 27 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+ closed {
+  id : string,
+  name : string?
+}
+
+create type testdv2.testtype02 as
+ closed {
+  id : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.2.update.sqlpp
new file mode 100644
index 0000000..5a90fc1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.2.update.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase name : open-closed-14.aql
+ * Description   : insert into target dataset - select * from source dataset
+ *               : in this case dataset1 and dataset2 are fo different schema.
+ * Success       : This test should succeed.
+ * Date          : March 27 2012
+ */
+
+use testdv2;
+
+
+insert into testds01
+select element {'id':'001'};
+insert into testds01
+select element {'id':'002','name':'John Doe'};
+insert into testds02
+select element {'id':'003'};
+insert into testds02
+select element {'id':'004'};
+insert into testds02
+select element {'id':'005'};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.3.query.sqlpp
new file mode 100644
index 0000000..ae101e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-14/open-closed-14.3.query.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.
+ */
+/*
+ * Testcase name : open-closed-14.aql
+ * Description   : insert into target dataset - select * from source dataset
+ *               : in this case dataset1 and dataset2 are fo different schema.
+ * Success       : This test should succeed.
+ * Date          : March 27 2012
+ */
+
+use testdv2;
+
+
+select element d
+from  testds01 as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.1.ddl.sqlpp
new file mode 100644
index 0000000..04c4d4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : open-closed-15.aql  
+ * Description    : Test closed type dataset (with primitives).
+ *                : Create Index on int 32 field
+ *                : Insert data into primitives and retrieve data.
+ * Success        : Yes this test should PASS!
+ * Date           : March 30th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id_8 : int8,
+  id_16 : int16,
+  id_32 : int32,
+  id_64 : int64,
+  fp : float,
+  name : string,
+  dt : date,
+  tm : time,
+  dt_tm : datetime,
+  lat_lon : point
+}
+
+create  table tdtst(Schema) primary key id_32;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.2.update.sqlpp
new file mode 100644
index 0000000..1fbb0c4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.2.update.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.
+ */
+/*
+ * Testcase Name  : open-closed-15.aql  
+ * Description    : Test closed type dataset (with primitives).
+ *                : Create Index on int 32 field
+ *                : Insert data into primitives and retrieve data.
+ * Success        : Yes this test should PASS!
+ * Date           : March 30th 2012
+ */
+
+use test;
+
+
+insert into tdtst
+{'id_8':100,'id_16':1011,'id_32':23455,'id_64':34567,'fp':87.618629f,'name':'John','dt':'03-21-1982','tm':test.time('10:50:56:200+05:00'),'dt_tm':test.datetime('2011-12-31T14:00:00-10:00'),'lat_lon':test.point('100.0,200.0')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.3.query.sqlpp
new file mode 100644
index 0000000..c4d0946
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-15/open-closed-15.3.query.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.
+ */
+/*
+ * Testcase Name  : open-closed-15.aql  
+ * Description    : Test closed type dataset (with primitives).
+ *                : Create Index on int 32 field
+ *                : Insert data into primitives and retrieve data.
+ * Success        : Yes this test should PASS!
+ * Date           : March 30th 2012
+ */
+
+use test;
+
+
+select element l
+from  tdtst as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.1.ddl.sqlpp
new file mode 100644
index 0000000..04167bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.1.ddl.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : open-closed-16.aql  
+ * Description    : Test open type dataset (with primitives).
+ *                : Create Index on int 32 field
+ *                : Insert data into primitives and retrieve data.
+ * Success        : Yes this test should PASS!
+ * Date           : March 30th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+{
+  id_8 : int8,
+  id_16 : int16,
+  id_32 : int32,
+  id_64 : int64,
+  fp : float,
+  name : string,
+  dt : date,
+  tm : time,
+  dt_tm : datetime,
+  lat_lon : point
+}
+
+create  table tdtst(Schema) primary key id_32;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.2.update.sqlpp
new file mode 100644
index 0000000..ff0405a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.2.update.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.
+ */
+/*
+ * Testcase Name  : open-closed-16.aql  
+ * Description    : Test open type dataset (with primitives).
+ *                : Create Index on int 32 field
+ *                : Insert data into primitives and retrieve data.
+ * Success        : Yes this test should PASS!
+ * Date           : March 30th 2012
+ */
+
+use test;
+
+
+insert into tdtst
+{'id_8':100,'id_16':1011,'id_32':23455,'id_64':34567,'fp':87.618629f,'name':'John','dt':'03-21-1982','tm':test.time('10:50:56:200+05:00'),'dt_tm':test.datetime('2011-12-31T14:00:00-10:00'),'lat_lon':test.point('100.0,200.0')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.3.query.sqlpp
new file mode 100644
index 0000000..dce3c8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-16/open-closed-16.3.query.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.
+ */
+/*
+ * Testcase Name  : open-closed-16.aql  
+ * Description    : Test open type dataset (with primitives).
+ *                : Create Index on int 32 field
+ *                : Insert data into primitives and retrieve data.
+ * Success        : Yes this test should PASS!
+ * Date           : March 30th 2012
+ */
+
+use test;
+
+
+select element l
+from  tdtst as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.1.ddl.sqlpp
new file mode 100644
index 0000000..4d56390
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.1.ddl.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.
+ */
+/*
+ * Testcase Name  :  open-closed-17.aql
+ * Description    :  Test open type dataset by inserting additional data along with inserting data for existing fields.
+ * Success        :  Yes
+ * Date           :  March 30th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+{
+  id_8 : int8,
+  id_16 : int16,
+  id_32 : int32,
+  id_64 : int64,
+  fp : float,
+  name : string,
+  dt : date,
+  tm : time,
+  dt_tm : datetime,
+  lat_lon : point
+}
+
+create  table tdtst(Schema) primary key id_32;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.2.update.sqlpp
new file mode 100644
index 0000000..f193fbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.2.update.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.
+ */
+/*
+ * Testcase Name  :  open-closed-17.aql
+ * Description    :  Test open type dataset by inserting additional data along with inserting data for existing fields.
+ * Success        :  Yes
+ * Date           :  March 30th 2012
+ */
+
+use test;
+
+
+insert into tdtst
+{'id_8':100,'id_16':1011,'id_32':23455,'id_64':34567,'fp':87.618629f,'name':'John','dt':'03-21-1982','tm':test.time('10:50:56:200+05:00'),'dt_tm':test.datetime('2011-12-31T14:00:00-10:00'),'lat_lon':test.point('100.0,200.0'),'mydata':{{'this is my additional data'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.3.query.sqlpp
new file mode 100644
index 0000000..fd3ee57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-17/open-closed-17.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name  :  open-closed-17.aql
+ * Description    :  Test open type dataset by inserting additional data along with inserting data for existing fields.
+ * Success        :  Yes
+ * Date           :  March 30th 2012
+ */
+
+use test;
+
+
+select element l
+from  tdtst as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.1.ddl.sqlpp
new file mode 100644
index 0000000..a907b34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.1.ddl.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.
+ */
+/*
+ * Test case name :  open-closed-19.aql
+ * Description    :  Insert into open type internal dataset by querying another internal dataset
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only n fields
+ * Success        :  Yes
+ * Date           :  29 April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.2.update.sqlpp
new file mode 100644
index 0000000..a907b34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.2.update.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.
+ */
+/*
+ * Test case name :  open-closed-19.aql
+ * Description    :  Insert into open type internal dataset by querying another internal dataset
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only n fields
+ * Success        :  Yes
+ * Date           :  29 April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.3.query.sqlpp
new file mode 100644
index 0000000..a907b34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-19/open-closed-19.3.query.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.
+ */
+/*
+ * Test case name :  open-closed-19.aql
+ * Description    :  Insert into open type internal dataset by querying another internal dataset
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only n fields
+ * Success        :  Yes
+ * Date           :  29 April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.1.ddl.sqlpp
new file mode 100644
index 0000000..e1f94e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name :  open-closed-20.aql
+ * Description    :  Insert into open type internal dataset by querying another internal dataset which is of open type with nullable fields
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only n fields, but has no intial records in it.
+ *                :  In this scenario, the source dataset (open) has some optional fields
+ * Success        :  Yes
+ * Date           :  May 01 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table dtst01(TestType) primary key id;
+
+create type test.Emp as
+{
+  id : int32,
+  name : string,
+  age : int8,
+  sex : string?,
+  dob : date?
+}
+
+create  table employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.2.update.sqlpp
new file mode 100644
index 0000000..770b6d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.2.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name :  open-closed-20.aql
+ * Description    :  Insert into open type internal dataset by querying another internal dataset which is of open type with nullable fields
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only n fields, but has no intial records in it.
+ *                :  In this scenario, the source dataset (open) has some optional fields
+ * Success        :  Yes
+ * Date           :  May 01 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.3.query.sqlpp
new file mode 100644
index 0000000..0b3be0e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-20/open-closed-20.3.query.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.
+ */
+/*
+ * Test case name :  open-closed-20.aql
+ * Description    :  Insert into open type internal dataset by querying another internal dataset which is of open type with nullable fields
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only n fields, but has no intial records in it.
+ *                :  In this scenario, the source dataset (open) has some optional fields
+ * Success        :  Yes
+ * Date           :  May 01 2012
+ */
+
+use test;
+
+
+select element l
+from  dtst01 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.1.ddl.sqlpp
new file mode 100644
index 0000000..2f1bf3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name :  open-closed-21.aql
+ * Description    :  Insert into open type internal dataset by querying another open type internal dataset
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only 1 field, but has no intial records in it.
+ * Success        :  Yes
+ * Date           :  29 April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table dtst01(TestType) primary key id;
+
+create type test.Emp as
+{
+  id : int32,
+  name : string,
+  age : int8,
+  sex : string,
+  dob : date
+}
+
+create  table employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.2.update.sqlpp
new file mode 100644
index 0000000..66b6efa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.2.update.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name :  open-closed-21.aql
+ * Description    :  Insert into open type internal dataset by querying another open type internal dataset
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only 1 field, but has no intial records in it.
+ * Success        :  Yes
+ * Date           :  29 April 2012
+ */
+
+use test;
+
+
+insert into employee
+select element {'id':201,'name':'John Doe','age':32,'sex':'M','dob':test.date('1975-01-11')};
+insert into employee
+select element {'id':202,'name':'John Smith','age':30,'sex':'M','dob':test.date('1982-07-12')};
+insert into employee
+select element {'id':203,'name':'John Wayne','age':62,'sex':'M','dob':test.date('1950-01-08')};
+insert into employee
+select element {'id':204,'name':'Roger Sanders','age':48,'sex':'M','dob':test.date('1972-11-12')};
+insert into employee
+select element {'id':205,'name':'Raj Singh','age':37,'sex':'M','dob':test.date('1978-05-06')};
+insert into employee
+select element {'id':206,'name':'Mike Tyson','age':44,'sex':'M','dob':test.date('1965-09-03')};
+insert into employee
+select element {'id':227,'name':'Mariam','age':30,'sex':'F','dob':test.date('1982-11-01')};
+insert into employee
+select element {'id':228,'name':'Cathy','age':35,'sex':'F','dob':test.date('1976-06-11'),'desgination':{{'Department Manager'}}};
+insert into dtst01
+select element l
+from  employee as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.3.query.sqlpp
new file mode 100644
index 0000000..79ecc61
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-21/open-closed-21.3.query.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.
+ */
+/*
+ * Test case name :  open-closed-21.aql
+ * Description    :  Insert into open type internal dataset by querying another open type internal dataset
+ *                :  In this case source dataset has (n+n) fields and the target dataset has only 1 field, but has no intial records in it.
+ * Success        :  Yes
+ * Date           :  29 April 2012
+ */
+
+use test;
+
+
+select element l
+from  dtst01 as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.1.ddl.sqlpp
new file mode 100644
index 0000000..60250b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name :  open-closed-22.aql
+ * Description    :  Insert into a closed type dataset which has nullable(optional) and non-nullable fields
+ * Success        :  Yes
+ * Date           :  30 April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+ closed {
+  id : int32,
+  name : string,
+  age : int8?,
+  dept : string?,
+  sex : string,
+  dob : date?
+}
+
+create  table employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.2.update.sqlpp
new file mode 100644
index 0000000..808fbd8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name :  open-closed-22.aql
+ * Description    :  Insert into a closed type dataset which has nullable(optional) and non-nullable fields
+ * Success        :  Yes
+ * Date           :  30 April 2012
+ */
+
+use test;
+
+
+insert into employee
+select element {'id':201,'name':'John Doe','age':37,'dept':'HR','sex':'M','dob':test.date('1975-11-02')};
+insert into employee
+select element {'id':202,'name':'John Smith','age':30,'dept':'Sales','sex':'M','dob':test.date('1982-12-12')};
+insert into employee
+select element {'id':201,'name':'John Wayne','age':62,'sex':'M'};
+insert into employee
+select element {'id':203,'name':'Roger Sanders','dept':'Technology','sex':'M','dob':test.date('1970-03-12')};
+insert into employee
+select element {'id':204,'name':'Raj Singh','sex':'M'};
+insert into employee
+select element {'id':205,'name':'Mike Tyson','age':44,'sex':'M','dob':test.date('1970-12-22')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.3.query.sqlpp
new file mode 100644
index 0000000..d78ab25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-22/open-closed-22.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case name :  open-closed-22.aql
+ * Description    :  Insert into a closed type dataset which has nullable(optional) and non-nullable fields
+ * Success        :  Yes
+ * Date           :  30 April 2012
+ */
+
+use test;
+
+
+select element l
+from  employee as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.1.ddl.sqlpp
new file mode 100644
index 0000000..a0e0dfb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : open-closed-24.aql
+ * Description   : Test use of additional data(open) field in create type statement
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int64,
+  name : string,
+  opt_tag : {{string}}
+}
+
+create  table testds(testType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.2.update.sqlpp
new file mode 100644
index 0000000..dfb639b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.2.update.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.
+ */
+/*
+ * Testcase Name : open-closed-24.aql
+ * Description   : Test use of additional data(open) field in create type statement 
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':32,'name':'UCI','opt_tag':{{'optional text','put any text here','and more'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.3.query.sqlpp
new file mode 100644
index 0000000..9e6b3a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-24/open-closed-24.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name : open-closed-24.aql
+ * Description   : Test use of additional data(open) field in create type statement 
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.1.ddl.sqlpp
new file mode 100644
index 0000000..88b8dfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : open-closed-25.aql
+ * Description   : Test use of additional data(open) optional field in create type statement
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int64,
+  name : string,
+  opt_tag : {{string}}?
+}
+
+create  table testds(testType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.2.update.sqlpp
new file mode 100644
index 0000000..ba78fb8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.2.update.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.
+ */
+/*
+ * Testcase Name : open-closed-25.aql
+ * Description   : Test use of additional data(open) optional field in create type statement 
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':32,'name':'UCI','opt_tag':{{'optional text','put any text here','and more'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.3.query.sqlpp
new file mode 100644
index 0000000..10954f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-25/open-closed-25.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name : open-closed-25.aql
+ * Description   : Test use of additional data(open) optional field in create type statement 
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.1.ddl.sqlpp
new file mode 100644
index 0000000..682ca96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : open-closed-26.aql
+ * Description   : Test use of additional data(open) optional field in create type statement
+ *               : No additional data is inserted (as it is declared as optional) from the insert statement.
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int64,
+  name : string,
+  opt_tag : {{string}}?
+}
+
+create  table testds(testType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.2.update.sqlpp
new file mode 100644
index 0000000..f7d51f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name : open-closed-26.aql
+ * Description   : Test use of additional data(open) optional field in create type statement 
+ *               : No additional data is inserted (as it is declared as optional) from the insert statement.
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':32,'name':'UCI'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.3.query.sqlpp
new file mode 100644
index 0000000..f309b1b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-26/open-closed-26.3.query.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.
+ */
+/*
+ * Testcase Name : open-closed-26.aql
+ * Description   : Test use of additional data(open) optional field in create type statement 
+ *               : No additional data is inserted (as it is declared as optional) from the insert statement.
+ * Success       : Yes
+ * Date          : 29th May 2012
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.1.ddl.sqlpp
new file mode 100644
index 0000000..6a75724
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : open-closed-28.aql
+ * Description    : Query for undeclared data from an open type internal dataset
+ *                : use the every keyword in the where clause
+ * Status         : Yes
+ * Date           : 31st May 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string,
+  name : string
+}
+
+create type testdv2.testtype02 as
+{
+  id : string,
+  name : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.2.update.sqlpp
new file mode 100644
index 0000000..ecd65e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.2.update.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.
+ */
+/*
+ * Testcase Name  : open-closed-28.aql
+ * Description    : Query for undeclared data from an open type internal dataset
+ *                : use the every keyword in the where clause
+ * Status         : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'001','name':'Person One','hobbies':{{'scuba','music'}}};
+insert into testds02
+select element {'id':'002','name':'Person Two','hobbies':{{'fishing','dance'}}};
+insert into testds02
+select element {'id':'003','name':'Person Three','hobbies':{{'hiking','surfing'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.3.query.sqlpp
new file mode 100644
index 0000000..26fb329
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-28/open-closed-28.3.query.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.
+ */
+/*
+ * Testcase Name  : open-closed-28.aql
+ * Description    : Query for undeclared data from an open type internal dataset
+ *                : use the every keyword in the where clause
+ * Status         : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+select element d
+from  testds01 as d
+where every h in d.hobbies satisfies (h = 'hiking')
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.1.ddl.sqlpp
new file mode 100644
index 0000000..637ba5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : open-closed-29.aql
+ * Description    : Query for undeclared data from an open type internal dataset
+ *                : use the some keyword in the where clause
+ * Status         : Yes
+ * Date           : 31st May 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string,
+  name : string
+}
+
+create type testdv2.testtype02 as
+{
+  id : string,
+  name : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.2.update.sqlpp
new file mode 100644
index 0000000..b8650bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.2.update.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.
+ */
+/*
+ * Testcase Name  : open-closed-29.aql
+ * Description    : Query for undeclared data from an open type internal dataset
+ *                : use the some keyword in the where clause
+ * Status         : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'001','name':'Person One','hobbies':{{'scuba','music'}}};
+insert into testds02
+select element {'id':'002','name':'Person Two','hobbies':{{'fishing','dance'}}};
+insert into testds02
+select element {'id':'003','name':'Person Three','hobbies':{{'hiking','surfing'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.3.query.sqlpp
new file mode 100644
index 0000000..03d663b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-29/open-closed-29.3.query.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.
+ */
+/*
+ * Testcase Name  : open-closed-29.aql
+ * Description    : Query for undeclared data from an open type internal dataset
+ *                : use the some keyword in the where clause
+ * Status         : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+select element d
+from  testds01 as d
+where some h in d.hobbies satisfies (h = 'hiking')
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.1.ddl.sqlpp
new file mode 100644
index 0000000..47bd64b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.1.ddl.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.
+ */
+/*
+ * Test case Name : open-closed-30.aql
+ * Description    : Query undeclared data using every in the WHERE clause
+ *                : where every $h in $d.hobbies satisfies $h='hiking'
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string
+}
+
+create type testdv2.testtype02 as
+{
+  id : string,
+  name : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.2.update.sqlpp
new file mode 100644
index 0000000..74a1b97
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.2.update.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.
+ */
+/*
+ * Test case Name : open-closed-30.aql
+ * Description    : Query undeclared data using every in the WHERE clause
+ *                : where every $h in $d.hobbies satisfies $h='hiking'
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'011','name':'John Doe','hobbies':{{'scuba','music'}}};
+insert into testds02
+select element {'id':'102','name':'Roger Sanders','hobbies':{{'fishing','dance'}}};
+insert into testds02
+select element {'id':'203','name':'Phil Smith','hobbies':{{'hiking','surfing'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.3.query.sqlpp
new file mode 100644
index 0000000..e2fc60f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-30/open-closed-30.3.query.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.
+ */
+/*
+ * Test case Name : open-closed-30.aql
+ * Description    : Query undeclared data using every in the WHERE clause
+ *                : where every $h in $d.hobbies satisfies $h='hiking'
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+select element d.hobbies
+from  testds01 as d
+where every h in d.hobbies satisfies (h = 'hiking')
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.1.ddl.sqlpp
new file mode 100644
index 0000000..9102111
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.1.ddl.sqlpp
@@ -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.
+ */
+/*
+ * Test case Name : open-closed-31.aql
+ * Description    : 
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string
+}
+
+create type testdv2.testtype02 as
+{
+  id : string,
+  name : string
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.2.update.sqlpp
new file mode 100644
index 0000000..209df99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : open-closed-31.aql
+ * Description    : 
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'011','name':'John Doe','hobbies':{{'scuba','music'}}};
+insert into testds02
+select element {'id':'102','name':'Roger Sanders','hobbies':{{'fishing','dance'}}};
+insert into testds02
+select element {'id':'203','name':'Phil Smith','hobbies':{{'hiking','surfing'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.3.query.sqlpp
new file mode 100644
index 0000000..9c2cf08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-31/open-closed-31.3.query.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.
+ */
+/*
+ * Test case Name : open-closed-31.aql
+ * Description    : 
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+select element d.hobbies
+from  testds01 as d
+where some h in d.hobbies satisfies (h = 'hiking')
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.1.ddl.sqlpp
new file mode 100644
index 0000000..967ce00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : open-closed-32.aql
+ * Description    : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset 
+ *                : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string
+}
+
+create type testdv2.testtype02 as
+ closed {
+  id : string,
+  name : string,
+  sex : string,
+  dept : string,
+  salary : int32,
+  interests : {{string}}
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.2.update.sqlpp
new file mode 100644
index 0000000..6ce2059
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.2.update.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : open-closed-32.aql
+ * Description    : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset 
+ *                : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'011','name':'John Doe','sex':'Male','dept':'HR','salary':80000,'interests':{{'hiking','scuba','painting','biking'}}};
+insert into testds02
+select element {'id':'921','name':'John Smith','sex':'Male','dept':'Sales','salary':65000,'interests':{{'gardening','biking','reading','hiking','fishing'}}};
+insert into testds02
+select element {'id':'959','name':'Susan Malaika','sex':'Female','dept':'XML Dev','salary':200000,'interests':{{'XML','Web Services','Cloud','X-Forms','art','travelling'}}};
+insert into testds02
+select element {'id':'371','name':'Tom Sawyer','sex':'Male','dept':'Well Being','salary':90000,'interests':{{'tennis','scuba','running','biking'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.3.query.sqlpp
new file mode 100644
index 0000000..8519bf5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-32/open-closed-32.3.query.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.
+ */
+/*
+ * Test case Name : open-closed-32.aql
+ * Description    : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset 
+ *                : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+select element d.interests
+from  testds01 as d
+where some h in d.interests satisfies (h = 'biking')
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.1.ddl.sqlpp
new file mode 100644
index 0000000..16b25d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.1.ddl.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.
+ */
+/*
+ * Test case Name : open-closed-33.aql
+ * Description    : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset
+ *                : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
+ *                : Here the interests field is optional.
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+drop  database testdv2 if exists;
+create  database testdv2;
+
+use testdv2;
+
+
+create type testdv2.testtype01 as
+{
+  id : string
+}
+
+create type testdv2.testtype02 as
+ closed {
+  id : string,
+  name : string,
+  sex : string,
+  dept : string,
+  salary : int32,
+  interests : {{string}}?
+}
+
+create  table testds01(testtype01) primary key id;
+
+create  table testds02(testtype02) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.2.update.sqlpp
new file mode 100644
index 0000000..226f5ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : open-closed-33.aql
+ * Description    : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset
+ *                : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
+ *                : Here the interests field is optional.
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+insert into testds02
+select element {'id':'011','name':'John Doe','sex':'Male','dept':'HR','salary':80000,'interests':{{'hiking','scuba','painting','biking'}}};
+insert into testds02
+select element {'id':'921','name':'John Smith','sex':'Male','dept':'Sales','salary':65000,'interests':{{'gardening','biking','reading','hiking','fishing'}}};
+insert into testds02
+select element {'id':'959','name':'Susan Malaika','sex':'Female','dept':'XML Dev','salary':200000,'interests':{{'XML','Web Services','Cloud','X-Forms','art','travelling'}}};
+insert into testds02
+select element {'id':'371','name':'Tom Sawyer','sex':'Male','dept':'Well Being','salary':90000,'interests':{{'tennis','scuba','running','biking'}}};
+insert into testds01
+select element d
+from  testds02 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.3.query.sqlpp
new file mode 100644
index 0000000..af49784
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/open-closed-33/open-closed-33.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : open-closed-33.aql
+ * Description    : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset
+ *                : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
+ *                : Here the interests field is optional.
+ * Success        : Yes
+ * Date           : 31st May 2012
+ */
+
+use testdv2;
+
+
+select element d.interests
+from  testds01 as d
+where some h in d.interests satisfies (h = 'biking')
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.1.ddl.sqlpp
new file mode 100644
index 0000000..c4119e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue134
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.2.update.sqlpp
new file mode 100644
index 0000000..c4119e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue134
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.3.query.sqlpp
new file mode 100644
index 0000000..76c4d51
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue134/query-issue134.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue134
+
+{{[1,2,3,4,5],[6,5,3,8,9],[44,22,66,-1,0,99.9]}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.1.ddl.sqlpp
new file mode 100644
index 0000000..3546886
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue166
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.2.update.sqlpp
new file mode 100644
index 0000000..3546886
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue166
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.3.query.sqlpp
new file mode 100644
index 0000000..3c3a983
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue166/query-issue166.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue166
+
+[[1,2,3],[4,5,6,7]][1];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.1.ddl.sqlpp
new file mode 100644
index 0000000..6831a3a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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  : This test case is to verify the fix for issue196
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testtype1 as
+{
+  id : int64
+}
+
+create type test.testtype2 as
+{
+  id : int64
+}
+
+create  table t1(testtype1) primary key id;
+
+create  table t2(testtype2) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.2.update.sqlpp
new file mode 100644
index 0000000..e1492e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.2.update.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : This test case is to verify the fix for issue196
+
+use test;
+
+
+insert into t1
+select element {'id':24};
+insert into t1
+select element {'id':23};
+insert into t1
+select element {'id':21};
+insert into t1
+select element {'id':44};
+insert into t1
+select element {'id':64};
+insert into t2
+select element {'id':24};
+insert into t2
+select element {'id':23};
+insert into t2
+select element {'id':21};
+insert into t2
+select element {'id':44};
+insert into t2
+select element {'id':64};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.3.query.sqlpp
new file mode 100644
index 0000000..7093721
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue196/query-issue196.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue196
+
+use test;
+
+
+{'a':(
+    select element l
+    from  t1 as l
+    order by l.id
+),'b':(
+    select element m
+    from  t2 as m
+    order by m.id
+)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.1.ddl.sqlpp
new file mode 100644
index 0000000..404bc01
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.1.ddl.sqlpp
@@ -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  : This test case is to verify the fix for issue208
+
+drop  database OpenSocialNetworkData if exists;
+create  database OpenSocialNetworkData;
+
+use OpenSocialNetworkData;
+
+
+create type OpenSocialNetworkData.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type OpenSocialNetworkData.TweetMessageType as
+{
+  tweetid : string,
+  "tweetid-copy" : string,
+  "send-time-copy" : datetime
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.2.update.sqlpp
new file mode 100644
index 0000000..c16c39b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue208
+
+use OpenSocialNetworkData;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_messages.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.3.query.sqlpp
new file mode 100644
index 0000000..5d074da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue208/query-issue208.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue208
+
+use OpenSocialNetworkData;
+
+
+select element {'user':uid,'count':OpenSocialNetworkData.count(t)}
+from  TweetMessages as t
+where ((t."send-time" >= OpenSocialNetworkData.datetime('2005-04-13T17:17:22')) and (t."send-time" <= OpenSocialNetworkData.datetime('2011-04-13T17:18:22')))
+group by t.user."screen-name" as uid
+order by uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.1.ddl.sqlpp
new file mode 100644
index 0000000..f1362c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : This test case is to verify the fix for issue236
+
+drop  database SocialNetworkData if exists;
+create  database SocialNetworkData;
+
+use SocialNetworkData;
+
+
+create type SocialNetworkData.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type SocialNetworkData.TweetMessageType as
+ closed {
+  tweetid : string,
+  "tweetid-copy" : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "send-time-copy" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.2.update.sqlpp
new file mode 100644
index 0000000..16c829b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue236
+
+use SocialNetworkData;
+
+
+insert into TweetMessages
+select element {'tweetid':'1111387810','tweetid-copy':'1111387810','user':{'screen-name':'TonyNapier#786','lang':'en','friends_count':4241366,'statuses_count':97,'name':'Tony Napier','followers_count':5984113},'sender-location':SocialNetworkData.point('29.24,78.35'),'send-time':SocialNetworkData.datetime('2011-11-24T14:24:51.000Z'),'send-time-copy':SocialNetworkData.datetime('2011-11-24T14:24:51.000Z'),'referred-topics':{{'sprint','wireless'}},'message-text':' love sprint its wireless is mind-blowing:)'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.3.query.sqlpp
new file mode 100644
index 0000000..9e40771
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue236/query-issue236.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue236
+
+use SocialNetworkData;
+
+
+select element r
+from  TweetMessages as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.1.ddl.sqlpp
new file mode 100644
index 0000000..6801460
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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  : This test case is to verify the fix for issue258
+
+drop  database test if exists;
+create  database test if not exists ;
+
+use test;
+
+
+create type test.t1 as
+ closed {
+  id : int64
+}
+
+create  table ds1(t1) primary key id;
+
+create  table ds2(t1) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.2.update.sqlpp
new file mode 100644
index 0000000..97bda95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue258
+
+use test;
+
+
+insert into ds1
+if ((test.count((
+      select element x
+      from  ds2 as x
+      where (x.id = 10)
+  )) <= 0))
+then {'id':10}
+else {'id':5};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.3.query.sqlpp
new file mode 100644
index 0000000..dfa1ef1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue258/query-issue258.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue258
+
+use test;
+
+
+select element d
+from  ds1 as d
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.1.ddl.sqlpp
new file mode 100644
index 0000000..165cbd3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue29
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.2.update.sqlpp
new file mode 100644
index 0000000..165cbd3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue29
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.3.query.sqlpp
new file mode 100644
index 0000000..5de1402
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue29/query-issue29.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue29
+
+{{{'tweetid':'1023','user':{'screen-name':'dflynn24','lang':'en','friends_count':46,'statuses_count':987,'name':'danielle flynn','followers_count':47},'sender-location':'40.904177,-72.958996','send-time':'2010-02-21T11:56:02-05:00','referred-topics':{{'verizon'}},'message-text':'i need a #verizon phone like nowwwww! :('},{'tweetid':'1024','user':{'screen-name':'miriamorous','lang':'en','friends_count':69,'statuses_count':1068,'name':'Miriam Songco','followers_count':78},'send-time':'2010-02-21T11:11:43-08:00','referred-topics':{{'commercials','verizon','att'}},'message-text':'#verizon & #att #commercials, so competitive'},{'tweetid':'1025','user':{'screen-name':'dj33','lang':'en','friends_count':96,'statuses_count':1696,'name':'Don Jango','followers_count':22},'send-time':'2010-02-21T12:38:44-05:00','referred-topics':{{'charlotte'}},'message-text':'Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales'},{'tweetid':'1026','user':{'screen-name':'reallyleila','lang':'en','friends_count':106,'statuses_count':107,'name':'Leila Samii','followers_count':52},'send-time':'2010-02-21T21:31:57-06:00','referred-topics':{{'verizon','at&t','iphone'}},'message-text':'I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!'}}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.1.ddl.sqlpp
new file mode 100644
index 0000000..23f9c00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.1.ddl.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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  : This test case is to verify the fix for issue343.  It is a more general case.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.AllType as
+{
+  id : int64,
+  name : string,
+  age : float,
+  salary : double,
+  married : boolean,
+  interests : {{string}},
+  children : [string],
+  address : AddressType,
+  dob : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  location2d : point,
+  location3d : point3d,
+  line : line,
+  polygon : polygon,
+  circle : circle
+}
+
+create type test.MyListType as
+{
+  id : int64,
+  mylist : [string]
+}
+
+create  table "All"(AllType) primary key id;
+
+create  table MyList(MyListType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.2.update.sqlpp
new file mode 100644
index 0000000..898e8a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue343.  It is a more general case.
+
+use test;
+
+
+insert into MyList
+select element {'id':1,'mylist':['blah']};
+insert into "All"
+select element record
+from  MyList as m
+with  record as {'id':13,'name':test.string('Nancy'),'age':32.500000f,'salary':12.0,'married':test.boolean('true'),'interests':{{'reading','writing'}},'children':['Brad','Scott'],'address':{'number':8389,'street':'Hill St.','city':'Mountain View'},'dob':test.date('-2011-01-27'),'time':test.time('12:20:30Z'),'datetime':test.datetime('-1951-12-27T12:20:30'),'duration':test.duration('P10Y11M12DT10H50M30S'),'location2d':test.point('41.00,44.00'),'location3d':test.point3d('44.00,13.00,41.00'),'line':test.line('10.1,11.1 10.2,11.2'),'polygon':test.polygon('1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8'),'circle':test.circle('10.1,11.1 10.2'),'mylist':m.mylist}
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.3.query.sqlpp
new file mode 100644
index 0000000..5636223
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343-2/query-issue343-2.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue343.  It is a more general case.
+
+use test;
+
+
+select element x
+from  "All" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.1.ddl.sqlpp
new file mode 100644
index 0000000..1b54be1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue343
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.AllType as
+{
+  id : int64,
+  name : string,
+  age : float,
+  salary : double,
+  married : boolean,
+  interests : {{string}},
+  children : [string],
+  address : AddressType,
+  dob : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  location2d : point,
+  location3d : point3d,
+  line : line,
+  polygon : polygon,
+  circle : circle
+}
+
+create  table "All"(AllType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.2.update.sqlpp
new file mode 100644
index 0000000..b9390d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue343
+
+use test;
+
+
+insert into "All"
+{'id':13,'name':test.string('Nancy'),'age':32.500000f,'salary':12.0,'married':test.boolean('true'),'interests':{{'reading','writing'}},'children':['Brad','Scott'],'address':{'number':8389,'street':'Hill St.','city':'Mountain View'},'dob':test.date('-2011-01-27'),'time':test.time('12:20:30Z'),'datetime':test.datetime('-1951-12-27T12:20:30'),'duration':test.duration('P10Y11M12DT10H50M30S'),'location2d':test.point('41.00,44.00'),'location3d':test.point3d('44.00,13.00,41.00'),'line':test.line('10.1,11.1 10.2,11.2'),'polygon':test.polygon('1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8'),'circle':test.circle('10.1,11.1 10.2'),'mylist':['blah']};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.3.query.sqlpp
new file mode 100644
index 0000000..6c85182
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue343/query-issue343.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue343
+
+use test;
+
+
+select element x
+from  "All" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.1.ddl.sqlpp
new file mode 100644
index 0000000..95555d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue350
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TweetMessageType as
+{
+  tweetid : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.2.update.sqlpp
new file mode 100644
index 0000000..3137476
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue350
+
+use TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_messages.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'tweetid':'13','user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39345,'statuses_count':479,'name':'Nathan Giesen','followers_count':49420,'hobbies':['basket weaving','mud wrestling']},'sender-location':TinySocial.point('47.44,80.65'),'send-time':TinySocial.datetime('2008-04-26T10:10:35'),'referred-topics':{{'tweeting'}},'message-text':'tweety tweet, my fellow tweeters!'};
+insert into TweetMessages
+select element {'tweetid':'15','user':{'screen-name':'Jason17','lang':'en','friends_count':393,'statuses_count':47,'name':'Nathan Giesen','followers_count':420,'hobbies':['swimming']},'sender-location':TinySocial.point('49.44,80.65'),'send-time':TinySocial.datetime('2009-04-26T10:10:35'),'referred-topics':{{'nothing'}},'message-text':'Nothing to say!'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.3.query.sqlpp
new file mode 100644
index 0000000..0028458
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350-2/query-issue350-2.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue350
+
+use TinySocial;
+
+
+select element tm
+from  TweetMessages as tm
+where every h in tm.user.hobbies satisfies (h = 'basket weaving')
+order by tm.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.1.ddl.sqlpp
new file mode 100644
index 0000000..95555d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue350
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TweetMessageType as
+{
+  tweetid : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.2.update.sqlpp
new file mode 100644
index 0000000..3137476
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue350
+
+use TinySocial;
+
+
+load  table TweetMessages using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_messages.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element {'tweetid':'13','user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39345,'statuses_count':479,'name':'Nathan Giesen','followers_count':49420,'hobbies':['basket weaving','mud wrestling']},'sender-location':TinySocial.point('47.44,80.65'),'send-time':TinySocial.datetime('2008-04-26T10:10:35'),'referred-topics':{{'tweeting'}},'message-text':'tweety tweet, my fellow tweeters!'};
+insert into TweetMessages
+select element {'tweetid':'15','user':{'screen-name':'Jason17','lang':'en','friends_count':393,'statuses_count':47,'name':'Nathan Giesen','followers_count':420,'hobbies':['swimming']},'sender-location':TinySocial.point('49.44,80.65'),'send-time':TinySocial.datetime('2009-04-26T10:10:35'),'referred-topics':{{'nothing'}},'message-text':'Nothing to say!'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.3.query.sqlpp
new file mode 100644
index 0000000..1094285
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue350/query-issue350.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue350
+
+use TinySocial;
+
+
+select element tm
+from  TweetMessages as tm
+where some h in tm.user.hobbies satisfies (h = 'basket weaving')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.1.ddl.sqlpp
new file mode 100644
index 0000000..8768002
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : This test case is to verify the fix for issue377
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string
+}
+
+create type TinySocial.TweetMessageType as
+{
+  tweetid : string
+}
+
+create type TinySocial.FacebookUserType as
+{
+  id : int64
+}
+
+create type TinySocial.FacebookMessageType as
+{
+  "message-id" : int64
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.2.update.sqlpp
new file mode 100644
index 0000000..55a6b12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.2.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue377
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/fbu-dml-insert-shuffled.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/twitter/tw_messages.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.3.query.sqlpp
new file mode 100644
index 0000000..813b766
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue377/query-issue377.3.query.sqlpp
@@ -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  : This test case is to verify the fix for issue377
+
+use TinySocial;
+
+
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'id':fbu.id,'name':fbu.name,'similar-users':(
+        select element {'twitter-screenname':tu."screen-name",'twitter-name':tu.name}
+        from  TweetMessages as t
+        with  tu as t.user
+        where (tu.name ~= fbu.name)
+    )}
+from  FacebookUsers as fbu
+order by fbu.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.1.ddl.sqlpp
new file mode 100644
index 0000000..dc10c8a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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  : This test case is to verify the fix for issue410
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+{
+  id : int32,
+  name : string
+}
+
+create  table Employee(Emp) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.2.update.sqlpp
new file mode 100644
index 0000000..96ed046
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue410
+
+use test;
+
+
+insert into Employee
+select element {'id':test.float('59138237473282.3293'),'name':test.double('0.01')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.3.query.sqlpp
new file mode 100644
index 0000000..b02636f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue410/query-issue410.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue410
+
+use test;
+
+
+select element x
+from  Employee as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.1.ddl.sqlpp
new file mode 100644
index 0000000..3f8fac1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue423
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table t2(TestType) primary key fname,lname;
+
+create  table t1(TestType) primary key fname,lname;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.2.update.sqlpp
new file mode 100644
index 0000000..218435a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue423
+
+use test;
+
+
+insert into t1
+select element {'id':123,'fname':'John','lname':'Doe'};
+insert into t1
+select element {'id':122,'fname':'Bruce','lname':'Li'};
+insert into t2
+select element {'id':23,'fname':'John','lname':'Doe'};
+insert into t2
+select element {'id':24,'fname':'Ravi','lname':'Khanna'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.3.query.sqlpp
new file mode 100644
index 0000000..6eca3fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423-2/query-issue423-2.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue423
+
+use test;
+
+
+select element {'l':l,'m':m}
+from  t1 as l,
+      t2 as m
+where (l.age > m.age)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.1.ddl.sqlpp
new file mode 100644
index 0000000..3f8fac1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue423
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table t2(TestType) primary key fname,lname;
+
+create  table t1(TestType) primary key fname,lname;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.2.update.sqlpp
new file mode 100644
index 0000000..218435a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue423
+
+use test;
+
+
+insert into t1
+select element {'id':123,'fname':'John','lname':'Doe'};
+insert into t1
+select element {'id':122,'fname':'Bruce','lname':'Li'};
+insert into t2
+select element {'id':23,'fname':'John','lname':'Doe'};
+insert into t2
+select element {'id':24,'fname':'Ravi','lname':'Khanna'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.3.query.sqlpp
new file mode 100644
index 0000000..cec7b78
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue423/query-issue423.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue423
+
+use test;
+
+
+select element {'l':l,'m':m}
+from  t1 as l,
+      t2 as m
+where (l.name = m.name)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue442/query-issue442.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue442/query-issue442.3.query.sqlpp
new file mode 100644
index 0000000..76bb659
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue442/query-issue442.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue442
+
+select element a
+from  [{'f':100},{'f':0},{'f':-1},{'f':null},{'f':999999},{'f':1},{'f':'zzzzz'}] as a
+order by a.f desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.1.ddl.sqlpp
new file mode 100644
index 0000000..caf137a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue453
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TypeOpen as
+{
+  id : int64,
+  int_m : int64,
+  int_o : int64?,
+  string_m : string,
+  string_o : string?
+}
+
+create  table DataOpen(TypeOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.2.update.sqlpp
new file mode 100644
index 0000000..953307c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue453
+
+use test;
+
+
+insert into DataOpen
+select element {'id':pos,'int_m':arr[0],'int_o':arr[1],'string_m':arr[2],'string_o':arr[3]}
+from  (
+    select element [i1,i2,s1,s2]
+    from  [1,2] as i1,
+          [1,null] as i2,
+          ['a','b'] as s1,
+          ['a',null] as s2
+) as arr at pos
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.3.query.sqlpp
new file mode 100644
index 0000000..d483474
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453-2/query-issue453-2.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue453
+
+use test;
+
+
+select element d
+from  DataOpen as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.1.ddl.sqlpp
new file mode 100644
index 0000000..caf137a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue453
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TypeOpen as
+{
+  id : int64,
+  int_m : int64,
+  int_o : int64?,
+  string_m : string,
+  string_o : string?
+}
+
+create  table DataOpen(TypeOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.2.update.sqlpp
new file mode 100644
index 0000000..9efab99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.2.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue453
+
+use test;
+
+
+insert into DataOpen
+select element o
+from  {{{'id':0,'int_m':1,'int_o':1,'string_m':'a','string_o':'a'},{'id':1,'int_m':1,'int_o':1,'string_m':'a','string_o':null}}} as o
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.3.query.sqlpp
new file mode 100644
index 0000000..d483474
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue453/query-issue453.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue453
+
+use test;
+
+
+select element d
+from  DataOpen as d
+order by d.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.1.ddl.sqlpp
new file mode 100644
index 0000000..46c99a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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  : This test case is to verify the fix for issue456:
+ *                https://code.google.com/p/asterixdb/issues/detail?id=456
+ * Expected Res : SUCCESS
+ * Date         : 3rd June 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TypeOpen as
+{
+  id : int64,
+  int_m : int64,
+  int_o : int64?,
+  string_m : string,
+  string_o : string?
+}
+
+create  table DataOpen(TypeOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.2.update.sqlpp
new file mode 100644
index 0000000..daebe28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.2.update.sqlpp
@@ -0,0 +1,60 @@
+/*
+ * 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  : This test case is to verify the fix for issue456: 
+ *                https://code.google.com/p/asterixdb/issues/detail?id=456
+ * Expected Res : SUCCESS
+ * Date         : 3rd June 2013
+ */
+
+use test;
+
+
+insert into DataOpen
+select element {'id':0,'int_m':1,'int_o':1,'string_m':'a','string_o':'a'};
+insert into DataOpen
+select element {'id':1,'int_m':1,'int_o':1,'string_m':'a','string_o':null};
+insert into DataOpen
+select element {'id':2,'int_m':1,'int_o':1,'string_m':'b','string_o':'a'};
+insert into DataOpen
+select element {'id':3,'int_m':1,'int_o':1,'string_m':'b','string_o':null};
+insert into DataOpen
+select element {'id':4,'int_m':1,'int_o':null,'string_m':'a','string_o':'a'};
+insert into DataOpen
+select element {'id':5,'int_m':1,'int_o':null,'string_m':'a','string_o':null};
+insert into DataOpen
+select element {'id':6,'int_m':1,'int_o':null,'string_m':'b','string_o':'a'};
+insert into DataOpen
+select element {'id':7,'int_m':1,'int_o':null,'string_m':'b','string_o':null};
+insert into DataOpen
+select element {'id':8,'int_m':2,'int_o':1,'string_m':'a','string_o':'a'};
+insert into DataOpen
+select element {'id':9,'int_m':2,'int_o':1,'string_m':'a','string_o':null};
+insert into DataOpen
+select element {'id':10,'int_m':2,'int_o':1,'string_m':'b','string_o':'a'};
+insert into DataOpen
+select element {'id':11,'int_m':2,'int_o':1,'string_m':'b','string_o':null};
+insert into DataOpen
+select element {'id':12,'int_m':2,'int_o':null,'string_m':'a','string_o':'a'};
+insert into DataOpen
+select element {'id':13,'int_m':2,'int_o':null,'string_m':'a','string_o':null};
+insert into DataOpen
+select element {'id':14,'int_m':2,'int_o':null,'string_m':'b','string_o':'a'};
+insert into DataOpen
+select element {'id':15,'int_m':2,'int_o':null,'string_m':'b','string_o':null};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.3.query.sqlpp
new file mode 100644
index 0000000..dd08a0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue456/query-issue456.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue456: 
+ *                https://code.google.com/p/asterixdb/issues/detail?id=456
+ * Expected Res : SUCCESS
+ * Date         : 3rd June 2013
+ */
+
+use test;
+
+
+select element [m,test.count(id)]
+from  DataOpen as x
+with  id as x.id
+group by x.int_m as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.1.ddl.sqlpp
new file mode 100644
index 0000000..4f3a0fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue465: 
+ *                https://code.google.com/p/asterixdb/issues/detail?id=465
+ * Expected Res : SUCCESS
+ * Date         : 3rd June 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.2.update.sqlpp
new file mode 100644
index 0000000..4f3a0fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue465: 
+ *                https://code.google.com/p/asterixdb/issues/detail?id=465
+ * Expected Res : SUCCESS
+ * Date         : 3rd June 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.3.query.sqlpp
new file mode 100644
index 0000000..a3d2c7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue465/query-issue465.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue465: 
+ *                https://code.google.com/p/asterixdb/issues/detail?id=465
+ * Expected Res : SUCCESS
+ * Date         : 3rd June 2013
+ */
+
+[{'r1':1234},{'r2':456}];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.1.ddl.sqlpp
new file mode 100644
index 0000000..a20a6cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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  : This test case is to verify the fix for issue487
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmpType as
+{
+  id : int32,
+  name : string
+}
+
+create  table Employee(EmpType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.2.update.sqlpp
new file mode 100644
index 0000000..2ece321
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue487
+
+use test;
+
+
+insert into Employee
+select element {'id':123};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.3.query.sqlpp
new file mode 100644
index 0000000..d5bfbf5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue487/query-issue487.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue487
+
+use test;
+
+
+select element l
+from  Employee as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.1.ddl.sqlpp
new file mode 100644
index 0000000..9701d84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue55 query 1
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.2.update.sqlpp
new file mode 100644
index 0000000..9701d84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue55 query 1
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.3.query.sqlpp
new file mode 100644
index 0000000..0e5d9c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55-1/query-issue55-1.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue55 query 1
+
+with  l as [1.100000f,1.000000f,1.200000f,0.9,1.3,1,2]
+select element [i,j,'=',(i = j),'<',(i < j),'<=',(i <= j),'>',(i > j),'>=',(i >= j)]
+from  l as i,
+      l as j
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.1.ddl.sqlpp
new file mode 100644
index 0000000..b6d007e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue55 query 2
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.2.update.sqlpp
new file mode 100644
index 0000000..b6d007e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue55 query 2
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.3.query.sqlpp
new file mode 100644
index 0000000..ab17239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue55/query-issue55.3.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue55 query 2
+
+select element x
+from  [[1,3],[4,5,2],[-1,-3,0],['a']] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.1.ddl.sqlpp
new file mode 100644
index 0000000..686b69d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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     : Issue592
+ * Expected Result : Success
+ * Date            : 21 October 2013
+ * Notes           : This test was written to verify the fix for issue592.
+ */
+
+drop  database fooverse if exists;
+create  database fooverse;
+
+use fooverse;
+
+
+create type fooverse.bartype as
+{
+  baz : int64
+}
+
+create type fooverse.footype as
+{
+  id : int64,
+  bars : [bartype]?
+}
+
+create  table fooset(footype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.2.update.sqlpp
new file mode 100644
index 0000000..0a51fd4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Issue592
+ * Expected Result : Success
+ * Date            : 21 October 2013
+ * Notes           : This test was written to verify the fix for issue592.
+ */
+
+use fooverse;
+
+
+insert into fooset
+select element {'id':1,'bars':[{'baz':1},{'baz':1}]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.3.query.sqlpp
new file mode 100644
index 0000000..a96f3b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue592/query-issue592.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Issue592
+ * Expected Result : Success
+ * Date            : 21 October 2013
+ * Notes           : This test was written to verify the fix for issue592.
+ */
+
+use fooverse;
+
+
+select element f
+from  fooset as f
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.1.ddl.sqlpp
new file mode 100644
index 0000000..70cf629
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.1.ddl.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.
+ */
+/*
+ * Description     : Issue625
+ * Expected Result : Success
+ * Date            : 21 October 2013
+ * Notes           : This test was written to verify the fix for issue625.
+ */
+
+drop  database fooverse if exists;
+create  database fooverse;
+
+use fooverse;
+
+
+create type fooverse.FooType as
+{
+  id : int64,
+  numbers : [int64]
+}
+
+create  table Foo(FooType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.2.update.sqlpp
new file mode 100644
index 0000000..2f90fe3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.2.update.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.
+ */
+/*
+ * Description     : Issue592
+ * Expected Result : Success
+ * Date            : 21 October 2013
+ * Notes           : This test was written to verify the fix for issue592.
+ */
+
+use fooverse;
+
+
+insert into Foo
+{'id':1,'numbers':(
+    select element fooverse.int32(x)
+    from  ['1','2','3'] as x
+)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.3.query.sqlpp
new file mode 100644
index 0000000..fc44fa6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue625/query-issue625.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Issue592
+ * Expected Result : Success
+ * Date            : 21 October 2013
+ * Notes           : This test was written to verify the fix for issue592.
+ */
+
+use fooverse;
+
+
+select element x
+from  Foo as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.1.ddl.sqlpp
new file mode 100644
index 0000000..590daab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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     : Issue656
+ * Expected Result : Success
+ * Date            : 6 December 2013
+ * Notes           : This test was written to verify the fix for issue656.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.bartype as
+{
+  id : uuid
+}
+
+create  table barset(bartype) primary key id autogenerated ;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.2.update.sqlpp
new file mode 100644
index 0000000..ea179c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Issue656
+ * Expected Result : Success
+ * Date            : 6 December 2013
+ * Notes           : This test was written to verify the fix for issue656.
+ */
+
+use test;
+
+
+insert into barset
+select element {};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.3.query.sqlpp
new file mode 100644
index 0000000..a190749
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-issue656/query-issue656.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Issue656
+ * Expected Result : Success
+ * Date            : 6 December 2013
+ * Notes           : This test was written to verify the fix for issue656.
+ */
+
+use test;
+
+
+select element b
+from  barset as b
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.1.ddl.sqlpp
new file mode 100644
index 0000000..ca42f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.1.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TweetMessageType as
+{
+  tweetid : string,
+  user : {
+      "screen-name" : string,
+      lang : string,
+      friends_count : int64,
+      statuses_count : int64,
+      name : string,
+      followers_count : int64
+  }
+,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.2.update.sqlpp
new file mode 100644
index 0000000..4f099f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ */
+
+use test;
+
+
+insert into TweetMessages
+select element {'tweetid':'1023','user':{'screen-name':'dflynn24','lang':'en','friends_count':46,'statuses_count':987,'name':'danielle flynn','followers_count':47},'sender-location':test."create-point"(40.904177,-72.958996),'send-time':test.datetime('2010-02-21T11:56:02-05:00'),'referred-topics':{{'verizon'}},'message-text':'i need a #verizon phone like nowwwww! : ('};
+insert into TweetMessages
+select element {'tweetid':'1024','user':{'screen-name':'miriamorous','lang':'en','friends_count':69,'statuses_count':1068,'name':'Miriam Songco','followers_count':78},'send-time':test.datetime('2010-02-21T11:11:43-08:00'),'referred-topics':{{'commercials','verizon','att'}},'message-text':'#verizon & #att #commercials, so competitive'};
+insert into TweetMessages
+select element {'tweetid':'1025','user':{'screen-name':'dj33','lang':'en','friends_count':96,'send-time':'2010-02-21T11:56:02-05:00','statuses_count':1696,'name':'Don Jango','followers_count':22},'send-time':test.datetime('2010-02-21T12:38:44-05:00'),'referred-topics':{{'charlotte'}},'message-text':'Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales'};
+insert into TweetMessages
+select element {'tweetid':'1026','user':{'screen-name':'reallyleila','lang':'en','friends_count':106,'statuses_count':107,'name':'Leila Samii','followers_count':52},'send-time':test.datetime('2010-02-21T21:31:57-06:00'),'referred-topics':{{'verizon','at&t','iphone'}},'message-text':'I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.3.query.sqlpp
new file mode 100644
index 0000000..8ef98d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal/query-proposal.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ */
+
+use test;
+
+
+select element {'topic':tp2,'count':test.count(tp1)}
+from  (
+    select element {'topic':tp}
+    from  TweetMessages as tweet,
+          tweet."referred-topics" as tp
+    where some topic in tweet."referred-topics" satisfies test.contains(topic,'verizon')
+) as tp1
+group by tp1.topic as tp2
+order by tp2
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.1.ddl.sqlpp
new file mode 100644
index 0000000..2993613
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.1.ddl.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.
+ */
+/*
+ * Description     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ *                 : this is another variant of the test in query-proposal.aql
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TweetMessageType as
+{
+  tweetid : string,
+  user : {
+      "screen-name" : string,
+      lang : string,
+      friends_count : int64,
+      statuses_count : int64,
+      name : string,
+      followers_count : int64
+  }
+,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.2.update.sqlpp
new file mode 100644
index 0000000..debc710
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.2.update.sqlpp
@@ -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     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ *                 : this is another variant of the test in query-proposal.aql
+ */
+
+use test;
+
+
+insert into TweetMessages
+select element {'tweetid':'1023','user':{'screen-name':'dflynn24','lang':'en','friends_count':46,'statuses_count':987,'name':'danielle flynn','followers_count':47},'sender-location':test."create-point"(40.904177,-72.958996),'send-time':test.datetime('2010-02-21T11:56:02-05:00'),'referred-topics':{{'verizon'}},'message-text':'i need a #verizon phone like nowwwww! : ('};
+insert into TweetMessages
+select element {'tweetid':'1024','user':{'screen-name':'miriamorous','lang':'en','friends_count':69,'statuses_count':1068,'name':'Miriam Songco','followers_count':78},'send-time':test.datetime('2010-02-21T11:11:43-08:00'),'referred-topics':{{'commercials','verizon','att'}},'message-text':'#verizon & #att #commercials, so competitive'};
+insert into TweetMessages
+select element {'tweetid':'1025','user':{'screen-name':'dj33','lang':'en','friends_count':96,'send-time':'2010-02-21T11:56:02-05:00','statuses_count':1696,'name':'Don Jango','followers_count':22},'send-time':test.datetime('2010-02-21T12:38:44-05:00'),'referred-topics':{{'charlotte'}},'message-text':'Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales'};
+insert into TweetMessages
+select element {'tweetid':'1026','user':{'screen-name':'reallyleila','lang':'en','friends_count':106,'statuses_count':107,'name':'Leila Samii','followers_count':52},'send-time':test.datetime('2010-02-21T21:31:57-06:00'),'referred-topics':{{'verizon','at&t','iphone'}},'message-text':'I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.3.query.sqlpp
new file mode 100644
index 0000000..69462dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-closed/query-proposal02/query-proposal02.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Insert open data into internal dataset and query the open data
+ * Expected Result : Success
+ * Date            : 23rd October 2012
+ * Notes           : This test was written to cover the scenario which is used in the proposal.
+ *                 : this is another variant of the test in query-proposal.aql
+ */
+
+use test;
+
+
+select element {'topic':topic,'count':test.count(tweet)}
+from  TweetMessages as tweet,
+      tweet."referred-topics" as reftopic
+where some reftopic in tweet."referred-topics" satisfies test.contains(reftopic,'verizon')
+group by reftopic as topic
+order by topic
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/enforced-field-name-collision/enforced-field-name-collision.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/enforced-field-name-collision/enforced-field-name-collision.1.ddl.sqlpp
new file mode 100644
index 0000000..063eccb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/enforced-field-name-collision/enforced-field-name-collision.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int32,
+  "value" : string
+}
+
+create  table testDS(testType) primary key id;
+
+create  index testIdx  on testDS ("value":string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/enforced-field-type-collision/enforced-field-name-collision.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/enforced-field-type-collision/enforced-field-name-collision.1.ddl.sqlpp
new file mode 100644
index 0000000..97e94cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/enforced-field-type-collision/enforced-field-name-collision.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int32,
+  "value" : string
+}
+
+create  table testDS(testType) primary key id;
+
+create  index testIdx  on testDS ("value":int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/index-on-closed-type/index-on-closed-type.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/index-on-closed-type/index-on-closed-type.1.ddl.sqlpp
new file mode 100644
index 0000000..95351a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/index-on-closed-type/index-on-closed-type.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+ closed {
+  id : int32
+}
+
+create  table testDS(testType) primary key id;
+
+create  index testIdx  on testDS ("value":string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.sqlpp
new file mode 100644
index 0000000..30814cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.testType as
+{
+  id : int32
+}
+
+create  table testDS(testType) primary key id;
+
+create  index testIdx  on testDS ("value":string) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ddl.sqlpp
new file mode 100644
index 0000000..31789be
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Create an external dataset that contains records stored with text hdfs file format.
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialData.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index idx  on MyData (id:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.update.sqlpp
new file mode 100644
index 0000000..5964b88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.update.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.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.query.sqlpp
new file mode 100644
index 0000000..4e05340
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an external dataset that contains records stored with text hdfs file format.
+
+use test;
+
+
+select element d
+from  MyData as d
+where (d.id = 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
new file mode 100644
index 0000000..7e06403
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
@@ -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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (tweetid:int64) type btree enforced;
+
+create  index msgCountAIx  on TweetMessages (countA:int64) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (countB:int64) type btree enforced;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location":point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
new file mode 100644
index 0000000..ecf5895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
new file mode 100644
index 0000000..83ec5f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create external  table TweetMessages(TweetMessageType) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/tw_for_indexleftouterjoin.adm"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index IdIx  on TweetMessages (tweetid:int64) type btree enforced;
+
+create  index msgCountAIx  on TweetMessages (countA:int64) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (countB:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
new file mode 100644
index 0000000..90607b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.update.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741                 
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
new file mode 100644
index 0000000..6b44e0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.query.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.
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..9b05d81
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create external  table MyData(MyRecord) using "hdfs"(("hdfs"="hdfs://127.0.0.1:31888"),("path"="/asterix/spatialData.json"),("input-format"="text-input-format"),("format"="adm"));
+
+create  index rtree_index_point  on MyData (point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..8426681
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp
new file mode 100644
index 0000000..8bf5b2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open enforced index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp
new file mode 100644
index 0000000..3b4e711
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp
new file mode 100644
index 0000000..fb859e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open enforced index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index authors_index  on DBLPOpen (authors:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.sqlpp
new file mode 100644
index 0000000..4ea3ae7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.query.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.
+ */
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open enforced index on authors, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bid':b.id,'authors':a.authors}
+from  DBLPOpen as a,
+      CSX as b
+where (a.authors /*+ indexnl */  = b.authors)
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..9cf8f9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ddl.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerOpenType as
+{
+  cid : int64,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerOpenType) primary key cid;
+
+create  table Customerstmp(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
new file mode 100644
index 0000000..aaaaf68
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element c
+from  Customerstmp as c
+where (c.cid < 500)
+;
+insert into Customers
+select element {'cid':c.cid,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}
+from  Customerstmp as c
+where (c.cid >= 500)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..20fa31a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (name:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
new file mode 100644
index 0000000..060a78f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b,'ed':ed}
+from  Customers as a,
+      Customers2 as b
+with  ed as test."edit-distance"(a.name,b.name)
+where ((ed <= 4) and (a.cid < b.cid))
+order by ed,a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..358ec9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,70 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerOpenType as
+{
+  cid : int64,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create type test.CustomerType as
+ closed {
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : [string],
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create  table Customers(CustomerOpenType) primary key cid;
+
+create  table Customerstmp(CustomerType) primary key cid;
+
+create  table Customers2(CustomerType) primary key cid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..bf063db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.2.update.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table Customerstmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load  table Customers2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into Customers
+select element c
+from  Customerstmp as c
+where (c.cid < 500)
+;
+insert into Customers
+select element {'cid':c.cid,'age':c.age,'address':c.address,'interests':c.interests,'children':c.children}
+from  Customerstmp as c
+where (c.cid >= 500)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..06e7b0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on Customers (name:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..72f2c3b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b}
+from  Customers as a,
+      Customers2 as b
+where ((test."edit-distance"(a.name,b.name) <= 4) and (a.cid < b.cid))
+order by a.cid,b.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..c0d1f9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..6f7a235
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..9849d25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..68a5fd2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.sqlpp
@@ -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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLPOpen as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+order by jacc,a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..aa9ea7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.1.ddl.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..0a73387
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..4f8822d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index ngram_index  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..f8dd194
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'arec':a,'brec':b}
+from  DBLPOpen as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."gram-tokens"(a.title,3,false),test."gram-tokens"(b.title,3,false)) >= 0.500000f) and (a.id < b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
new file mode 100644
index 0000000..d5c6ceb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData1tmp(MyRecord) primary key id;
+
+create  table MyData1(MyRecordOpen) primary key id;
+
+create  table MyData2(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
new file mode 100644
index 0000000..637b758
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table MyData1tmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyData2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into MyData1
+select element c
+from  MyData1tmp as c
+where (c.id < 10)
+;
+insert into MyData1
+select element {'id':c.id,'kwds':c.kwds,'line1':c.line1,'line2':c.line2,'poly1':c.poly1,'poly2':c.poly2,'rec':c.rec,'circle':c.circle}
+from  MyData1tmp as c
+where (c.id >= 10)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
new file mode 100644
index 0000000..0a13d88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index rtree_index  on MyData1 (point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.sqlpp
new file mode 100644
index 0000000..cd7b35f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.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.
+ */
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an  open enforced RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'aid':a.id,'bid':b.id,'apt':a.point,'bp':b.point}
+from  MyData1 as a,
+      MyData2 as b
+where (test."spatial-intersect"(a.point,b.point) and (a.id != b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
new file mode 100644
index 0000000..aa88ab7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
new file mode 100644
index 0000000..7ed3bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
new file mode 100644
index 0000000..96f9671
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
new file mode 100644
index 0000000..19f5c00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b,'jacc':jacc}
+from  DBLPOpen as a,
+      CSX as b
+with  jacc as test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title))
+where ((jacc >= 0.500000f) and (a.id < b.id))
+order by jacc,a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..9fbe923
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.1.ddl.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int64,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table DBLPOpen(DBLPOpenType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..c401be6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.2.update.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..bfcf5cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+create  index keyword_index  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..63f6955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.4.query.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.
+ */
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element {'arec':a,'brec':b}
+from  DBLPOpen as a,
+      CSX as b
+where ((test."similarity-jaccard"(test."word-tokens"(a.title),test."word-tokens"(b.title)) >= 0.500000f) and (a.id < b.id))
+order by a.id,b.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..a181e64
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  table TweetMessagesTmp(TweetMessageType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (countB:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..f8a73ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element c
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'tweetid':c.tweetid,'user':c.user,'sender-location':c."sender-location",'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..7c26c1a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..a181e64
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  table TweetMessagesTmp(TweetMessageType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (countB:int64) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..f8a73ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element c
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'tweetid':c.tweetid,'user':c.user,'sender-location':c."sender-location",'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..7f1e799
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..88bb7e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  table TweetMessagesTmp(TweetMessageType) primary key tweetid;
+
+create  index msgNgramIx  on TweetMessages ("message-text":string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..2da3721
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element c
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'tweetid':c.tweetid,'user':c.user,'sender-location':c."sender-location",'send-time':c."send-time",'referred-topics':c."referred-topics",'countA':c.countA,'countB':c.countB}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..51c96ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use test;
+
+
+select element {'tweet':{'id':t1.tweetid,'topics':t1."message-text"},'similar-tweets':(
+        select element {'id':t2.tweetid,'topics':t2."message-text"}
+        from  TweetMessages as t2
+        with  sim as test."edit-distance-check"(t1."message-text",t2."message-text",7)
+        where (sim[0] and (t2.tweetid != t1.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessagesTmp as t1
+where (t1.tweetid > test.int64('240'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
new file mode 100644
index 0000000..6509454
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  table TweetMessagesTmp(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location":point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
new file mode 100644
index 0000000..99ce0c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element c
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'tweetid':c.tweetid,'user':c.user,'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA,'countB':c.countB}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.sqlpp
new file mode 100644
index 0000000..ffaca94
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where test."spatial-intersect"(t2."sender-location",n)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
new file mode 100644
index 0000000..6509454
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int64,
+  "statuses-count" : int64,
+  name : string,
+  "followers-count" : int64
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int64,
+  countB : int64
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  table TweetMessagesTmp(TweetMessageType) primary key tweetid;
+
+create  index twmSndLocIx  on TweetMessages ("sender-location":point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
new file mode 100644
index 0000000..99ce0c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+load  table TweetMessagesTmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into TweetMessages
+select element c
+from  TweetMessagesTmp as c
+where (c.tweetid < test.int64('125'))
+;
+insert into TweetMessages
+select element {'tweetid':c.tweetid,'user':c.user,'send-time':c."send-time",'referred-topics':c."referred-topics",'message-text':c."message-text",'countA':c.countA,'countB':c.countB}
+from  TweetMessagesTmp as c
+where (c.tweetid >= test.int64('125'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.sqlpp
new file mode 100644
index 0000000..80b518a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.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.
+ */
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use test;
+
+
+select element {'tweetid1':t1.tweetid,'loc1':t1."sender-location",'nearby-message':(
+        select element {'tweetid2':t2.tweetid,'loc2':t2."sender-location"}
+        from  TweetMessages as t2
+        where (test."spatial-intersect"(t2."sender-location",n) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+with  n as test."create-circle"(t1."sender-location",0.5)
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
new file mode 100644
index 0000000..69b3b31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 27th March, 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.EmpOpen as
+{
+  id : int64,
+  age : int64,
+  dept : string
+}
+
+create  table employee(Emp) primary key id;
+
+create  table employeeOpen(EmpOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
new file mode 100644
index 0000000..e9c1b8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 27th March, 2014
+ */
+
+use test;
+
+
+load  table employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into employeeOpen
+select element x
+from  employee as x
+where (x.id <= 1000)
+;
+insert into employeeOpen
+select element {'id':x.id,'age':x.age,'dept':x.dept}
+from  employee as x
+where (x.id > 1000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.sqlpp
new file mode 100644
index 0000000..02cd53a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.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.
+ */
+/*
+ * Description     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 27th March, 2014
+ */
+
+use test;
+
+
+create  index idx_employee_f_l_name  on employeeOpen (fname:string,lname:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp
new file mode 100644
index 0000000..247f543
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 27th March, 2014
+ */
+
+use test;
+
+
+select element {'id':l.id,'fname':l.fname,'lname':l.lname,'age':l.age,'dept':l.dept}
+from  employeeOpen as l
+where ((l.fname > 'Julio') and (l.lname > 'Mattocks') and (l.fname <= 'Micco') and (l.lname < 'Vangieson'))
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.sqlpp
new file mode 100644
index 0000000..34e196e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.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.
+ */
+/*
+ * Description     : Test that BTree open index is used in query plan
+ *                 : define the BTree open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 27th March 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create type test.EmpOpen as
+{
+  id : int64,
+  age : int64,
+  dept : string
+}
+
+create  table employee(Emp) primary key id;
+
+create  table employeeOpen(EmpOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
new file mode 100644
index 0000000..2007b05
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 27th March 2014
+ */
+
+use test;
+
+
+load  table employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into employeeOpen
+select element x
+from  employee as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.sqlpp
new file mode 100644
index 0000000..d62486b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.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.
+ */
+/*
+ * Description     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 27th March 2014
+ */
+
+use test;
+
+
+create  index idx_employee_f_l_name  on employeeOpen (fname:string,lname:string) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.sqlpp
new file mode 100644
index 0000000..b144730
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.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.
+ */
+/*
+ * Description     : Test that BTree enforced open index is used in query plan
+ *                 : define the BTree enforced open index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 27th March 2014
+ */
+
+use test;
+
+
+select element {'id':l.id,'fname':l.fname,'lname':l.lname,'age':l.age,'dept':l.dept}
+from  employeeOpen as l
+where ((l.fname = 'Julio') and (l.lname = 'Isa'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
new file mode 100644
index 0000000..ae86593
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderOpenType as
+{
+  o_orderkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table OrdersOpen(OrderOpenType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
new file mode 100644
index 0000000..3c0a1d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into OrdersOpen
+select element x
+from  Orders as x
+where (x.o_orderkey <= 4000)
+;
+insert into OrdersOpen
+select element {'o_orderkey':x.o_orderkey,'o_orderstatus':x.o_orderstatus,'o_totalprice':x.o_totalprice,'o_orderdate':x.o_orderdate,'o_orderpriority':x.o_orderpriority,'o_clerk':x.o_clerk,'o_shippriority':x.o_shippriority,'o_comment':x.o_comment}
+from  Orders as x
+where (x.o_orderkey > 4000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.sqlpp
new file mode 100644
index 0000000..fd2dd2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on OrdersOpen (o_custkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
new file mode 100644
index 0000000..433aa5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey,'o_orderstatus':o.o_orderstatus,'o_orderkey2':o2.o_orderkey,'o_custkey2':o2.o_custkey,'o_orderstatus2':o2.o_orderstatus}
+from  OrdersOpen as o,
+      OrdersOpen as o2
+where ((o.o_custkey = 20) and (o2.o_custkey = 10) and (o.o_orderstatus < o2.o_orderstatus))
+order by o.o_orderkey,o2.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..76a02da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table DBLPOpen(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.sqlpp
new file mode 100644
index 0000000..89c2a4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+where (x.id <= 50)
+;
+insert into test.DBLPOpen
+select element {'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}
+from  "test.DBLP" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..8ef6aab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
new file mode 100644
index 0000000..f21bb57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLPOpen as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..dc9800e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPType) primary key id on group1;
+
+create  table DBLP(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.sqlpp
new file mode 100644
index 0000000..f435e32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLP
+select element x
+from  "test.DBLPtmp" as x
+where (x.id <= 50)
+;
+insert into test.DBLP
+select element {'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}
+from  "test.DBLPtmp" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..fa22139
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
new file mode 100644
index 0000000..3e7d24c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':paper.id,'title':paper.title}
+from  DBLP as paper
+where test."edit-distance-contains"(paper.title,'Multmedia',1)[0]
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
new file mode 100644
index 0000000..0a85095
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table DBLPOpen(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.sqlpp
new file mode 100644
index 0000000..a9d4437
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+where (x.id <= 50)
+;
+insert into test.DBLPOpen
+select element {'id':c.id,'dblpid':c.dblpid,'title':c.title,'misc':c.misc}
+from  "test.DBLP" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.sqlpp
new file mode 100644
index 0000000..88b0e8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ddl.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;
+
+
+create  index ngram_index  on DBLPOpen (authors:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
new file mode 100644
index 0000000..35cbedd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLPOpen as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',5)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
new file mode 100644
index 0000000..dc9800e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLPtmp(DBLPType) primary key id on group1;
+
+create  table DBLP(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.sqlpp
new file mode 100644
index 0000000..f435e32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLPtmp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLP
+select element x
+from  "test.DBLPtmp" as x
+where (x.id <= 50)
+;
+insert into test.DBLP
+select element {'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}
+from  "test.DBLPtmp" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.sqlpp
new file mode 100644
index 0000000..fa22139
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ddl.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;
+
+
+create  index ngram_index  on DBLP (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
new file mode 100644
index 0000000..98db760
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'id':paper.id,'title':paper.title}
+from  DBLP as paper,
+      test."word-tokens"(paper.title) as word
+where test."edit-distance-check"(word,'Multmedia',1)[0]
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..0a85095
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table DBLPOpen(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..a9d4437
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+where (x.id <= 50)
+;
+insert into test.DBLPOpen
+select element {'id':c.id,'dblpid':c.dblpid,'title':c.title,'misc':c.misc}
+from  "test.DBLP" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.sqlpp
new file mode 100644
index 0000000..88b0e8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ddl.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;
+
+
+create  index ngram_index  on DBLPOpen (authors:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
new file mode 100644
index 0000000..e73e306
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLPOpen as o
+with  ed as test."edit-distance-check"(o.authors,'Amihay Motro',1)
+where ed[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..76a02da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table DBLPOpen(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..89c2a4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+where (x.id <= 50)
+;
+insert into test.DBLPOpen
+select element {'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}
+from  "test.DBLP" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..8ef6aab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ddl.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;
+
+
+create  index ngram_index  on DBLPOpen (title:string) type ngram (3) enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..6716175
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLPOpen as o
+with  jacc as test."similarity-jaccard-check"(test."gram-tokens"(o.title,3,false),test."gram-tokens"('Transactions for Cooperative Environments',3,false),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
new file mode 100644
index 0000000..76a02da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table DBLPOpen(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.sqlpp
new file mode 100644
index 0000000..89c2a4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+where (x.id <= 50)
+;
+insert into test.DBLPOpen
+select element {'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}
+from  "test.DBLP" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.sqlpp
new file mode 100644
index 0000000..f52d874
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ddl.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;
+
+
+create  index keyword_index  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
new file mode 100644
index 0000000..f21bb57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLPOpen as o
+where test.contains(o.title,'Multimedia')
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..76a02da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ddl.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.DBLPOpenType as
+{
+  id : int64,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
+create  table DBLPOpen(DBLPOpenType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..89c2a4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.update.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.
+ */
+
+use test;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
+insert into test.DBLPOpen
+select element x
+from  "test.DBLP" as x
+where (x.id <= 50)
+;
+insert into test.DBLPOpen
+select element {'id':c.id,'dblpid':c.dblpid,'authors':c.authors,'misc':c.misc}
+from  "test.DBLP" as c
+where (c.id > 50)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.sqlpp
new file mode 100644
index 0000000..f52d874
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ddl.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;
+
+
+create  index keyword_index  on DBLPOpen (title:string) type keyword enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
new file mode 100644
index 0000000..dc078d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id,'dblpid':o.dblpid,'title':o.title,'authors':o.authors,'misc':o.misc}
+from  DBLPOpen as o
+with  jacc as test."similarity-jaccard-check"(test."word-tokens"(o.title),test."word-tokens"('Transactions for Cooperative Environments'),0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
new file mode 100644
index 0000000..e2edd69
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderOpenType as
+{
+  o_orderkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table OrdersOpen(OrderOpenType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.sqlpp
new file mode 100644
index 0000000..2b643d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into OrdersOpen
+select element x
+from  Orders as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.sqlpp
new file mode 100644
index 0000000..fd2dd2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on OrdersOpen (o_custkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
new file mode 100644
index 0000000..bf1bb4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  OrdersOpen as o
+where ((o.o_custkey = 40) and (o.o_totalprice > 150000.0))
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
new file mode 100644
index 0000000..e2edd69
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.OrderOpenType as
+{
+  o_orderkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table OrdersOpen(OrderOpenType) primary key o_orderkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.2.update.sqlpp
new file mode 100644
index 0000000..2b643d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.2.update.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.
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into OrdersOpen
+select element x
+from  Orders as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.sqlpp
new file mode 100644
index 0000000..fd2dd2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.3.ddl.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 tpch;
+
+
+create  index idx_Orders_Custkey  on OrdersOpen (o_custkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
new file mode 100644
index 0000000..b1d2481
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element {'o_orderkey':o.o_orderkey,'o_custkey':o.o_custkey}
+from  OrdersOpen as o
+where (o.o_custkey = 40)
+order by o.o_orderkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.1.ddl.sqlpp
new file mode 100644
index 0000000..9058831
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type test.LineItemOpenType as
+{
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table LineItemOpen(LineItemOpenType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.2.update.sqlpp
new file mode 100644
index 0000000..ad3aef7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.2.update.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.
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into test.LineItemOpen
+select element x
+from  "test.LineItem" as x
+where (x.l_orderkey < 3000)
+;
+insert into test.LineItemOpen
+select element {'l_orderkey':x.l_orderkey,'l_partkey':x.l_partkey,'l_linenumber':x.l_linenumber,'l_quantity':x.l_quantity,'l_extendedprice':x.l_extendedprice,'l_discount':x.l_discount,'l_tax':x.l_tax,'l_returnflag':x.l_returnflag,'l_linestatus':x.l_linestatus,'l_shipdate':x.l_shipdate,'l_commitdate':x.l_commitdate,'l_receiptdate':x.l_receiptdate,'l_shipinstruct':x.l_shipinstruct,'l_shipmode':x.l_shipmode,'l_comment':x.l_comment}
+from  "test.LineItem" as x
+where (x.l_orderkey >= 3000)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.3.ddl.sqlpp
new file mode 100644
index 0000000..ff1f76d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.3.ddl.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;
+
+
+create  index idx_LineItem_suppkey  on LineItemOpen (l_suppkey:int32) type btree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.4.query.sqlpp
new file mode 100644
index 0000000..8e7cf08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/range-search/range-search.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element c
+from  LineItemOpen as c
+where ((c.l_suppkey < 100) and (c.l_suppkey > 5))
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..c0ac126
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyRecordOpen as
+{
+  id : int64,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create  table MyDataOpen(MyRecordOpen) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..56fdc36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.2.update.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.
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+insert into MyDataOpen
+select element c
+from  MyData as c
+where (c.id < 15)
+;
+insert into MyDataOpen
+select element {'id':c.id,'kwds':c.kwds,'line1':c.line1,'line2':c.line2,'poly1':c.poly1,'poly2':c.poly2,'rec':c.rec,'circle':c.circle}
+from  MyData as c
+where (c.id >= 15)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..281a06e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.3.ddl.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;
+
+
+create  index rtree_index_point  on MyDataOpen (point:point) type rtree enforced;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
new file mode 100644
index 0000000..fb4f0e6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.4.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyDataOpen as o
+where test."spatial-intersect"(o.point,test."create-polygon"([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.3.query.sqlpp
new file mode 100644
index 0000000..63db9cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_01/everysat_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [10,-30] as x
+where every y in [-20,-10] satisfies (y > x)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.1.ddl.sqlpp
new file mode 100644
index 0000000..5fb980f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.1.ddl.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.
+ */
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.2.update.sqlpp
new file mode 100644
index 0000000..5fb980f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.2.update.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.
+ */
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.3.query.sqlpp
new file mode 100644
index 0000000..6e52da3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_02/everysat_02.3.query.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.
+ */
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
+with  a as [every x in [1,2] satisfies ((x + x) = 3),every x in [1,1] satisfies ((x + x) = 2),every x in [1,2] satisfies ((x - 2) = 2),every x in [2,2] satisfies ((x - 2) = 0),every x in [1,2] satisfies ((x * 2) = 4),every x in [1,2] satisfies ((x / 2) = 1),every x in [1,2] satisfies ((x = 1) or (x = 2)),every x in [1,2] satisfies ((x = 1) and ((x + 1) = 2)),every x in ['A','B','C'] satisfies (x = 'A'),every x in [1,2,3],
+y in [4,5,6] satisfies ((x + y) = 5),every x in [1,2,3],
+y in [4,5,6] satisfies ((x - y) = 5),every x in [1,2,3],
+y in [4,5,6] satisfies ((x * y) = 10)]
+select element i
+from  a as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.1.ddl.sqlpp
new file mode 100644
index 0000000..5fb980f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.1.ddl.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.
+ */
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.2.update.sqlpp
new file mode 100644
index 0000000..5fb980f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.2.update.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.
+ */
+/*
+ * Description      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.3.query.sqlpp
new file mode 100644
index 0000000..67f08ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_03/everysat_03.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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      : Test Quantified Expressions 
+ *                  : every <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
+with  a as [every x in [1,2] satisfies (avg([x,1]) = 1),every x in ['1','2'] satisfies (string(x) = '1'),every x in ['1','2'] satisfies ("string-length"(x) = 1),every x in [[1,2],[10],[1,5,7,8]] satisfies (count(x) = 1),every x in [[2],[10],[8]] satisfies (count(x) = 1),every x in [true,false] satisfies boolean('true'),every x in [true,true] satisfies not(x),every x in [1,2,3],
+y in [4,5,6] satisfies ((x + y) = 5),every x in [1,2,3],
+y in [4,5,6] satisfies ((x - y) = 5),every x in [1,2,3],
+y in [4,5,6] satisfies ((x * y) = 10),every x in ['ab','cd'],
+y in ['ab','de'] satisfies (string(x) = string(y)),every x in [1,2,3],
+y in [4,5,6] satisfies (int32(x) = int32(y)),every x in [1,2,3],
+y in [4,5,6] satisfies (float(x) = float(y)),every x in [1,2,3],
+y in [4,5,6] satisfies (double(x) = double(y)),every x in ['true','false'],
+y in ['false','true'] satisfies (boolean(x) = boolean(y)),every x in ['1980-05-05T13:13:13Z','1980-05-05T13:13:13Z'],
+y in ['1980-05-05T13:13:13Z','1980-05-05T13:13:13Z'] satisfies (datetime(x) = datetime(y))]
+select element i
+from  a as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.1.ddl.sqlpp
new file mode 100644
index 0000000..8715f2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.1.ddl.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.
+ */
+/*
+ * Description    : Tests that universal quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.2.update.sqlpp
new file mode 100644
index 0000000..cf055e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.2.update.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.
+ */
+/*
+ * Description    : Tests that universal quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.3.query.sqlpp
new file mode 100644
index 0000000..d0b1915
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/everysat_04/everysat_04.3.query.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.
+ */
+/*
+ * Description    : Tests that universal quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  x as [every x in [false,false] satisfies x,every x in [true,false] satisfies x,every x in [false,true] satisfies x,every x in [true,true] satisfies x,every x in [false,false] satisfies test.not(x),every x in [true,false] satisfies test.not(x),every x in [false,true] satisfies test.not(x),every x in [true,true] satisfies test.not(x)]
+select element i
+from  x as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.3.query.sqlpp
new file mode 100644
index 0000000..44612b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_01/somesat_01.3.query.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.
+ */
+
+use test;
+
+
+select element x
+from  [10,-30,-21,50] as x
+where some y in [-20,-40] satisfies (y > x)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.1.ddl.sqlpp
new file mode 100644
index 0000000..d5238d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  lastorder : {
+      oid : int64,
+      total : float
+  }
+
+}
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create  table CustomerSomeSat02(CustomerType) primary key cid;
+
+create  table OrdersSomeSat02(OrderType) primary key oid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.2.update.sqlpp
new file mode 100644
index 0000000..bdd288e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.2.update.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.
+ */
+
+use test;
+
+
+load  table CustomerSomeSat02 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm"));
+
+load  table OrdersSomeSat02 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.3.query.sqlpp
new file mode 100644
index 0000000..49f592f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_02/somesat_02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element x.cid
+from  CustomerSomeSat02 as x
+where some y in OrdersSomeSat02 satisfies (y.cid = x.cid)
+order by x.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.1.ddl.sqlpp
new file mode 100644
index 0000000..2271a4a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.1.ddl.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.
+ */
+/*
+ * Description     : Test quantified expressions; some variable in [ordered list] satisfies expression.
+ * Expected Result : Success
+ * Date            : 6th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.2.update.sqlpp
new file mode 100644
index 0000000..2271a4a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.2.update.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.
+ */
+/*
+ * Description     : Test quantified expressions; some variable in [ordered list] satisfies expression.
+ * Expected Result : Success
+ * Date            : 6th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.3.query.sqlpp
new file mode 100644
index 0000000..61317e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_03/somesat_03.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test quantified expressions; some variable in [ordered list] satisfies expression.
+ * Expected Result : Success
+ * Date            : 6th July 2012
+ */
+
+with  a as [some x in [1,2] satisfies ((x + x) = 3),some x in [1,2] satisfies ((x + x) = 2),some x in [1,2] satisfies ((x - 2) = 2),some x in [1,2] satisfies ((x - 2) = 0),some x in [1,2] satisfies ((x * 2) = 4),some x in [1,2] satisfies ((x / 2) = 1),some x in [1,2] satisfies (avg([x,1]) = 1),some x in [1,2] satisfies boolean('true'),some x in [1,2] satisfies boolean('false'),some x in [true,false] satisfies not(x),some x in [1,2] satisfies ((x = 1) or (x = 2)),some x in [1,2] satisfies ((x = 1) and ((x + 1) = 2))]
+select element i
+from  a as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.1.ddl.sqlpp
new file mode 100644
index 0000000..61d7e66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.1.ddl.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.
+ */
+/*
+ * Description      : Test Quantified Expressions
+ *                  : some <variable-name> in [ordered-list] satisfies function expression
+ *                  : some <variable-name> in [ordered-list],<variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.2.update.sqlpp
new file mode 100644
index 0000000..61d7e66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.2.update.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.
+ */
+/*
+ * Description      : Test Quantified Expressions
+ *                  : some <variable-name> in [ordered-list] satisfies function expression
+ *                  : some <variable-name> in [ordered-list],<variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.3.query.sqlpp
new file mode 100644
index 0000000..c29caa7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_04/somesat_04.3.query.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.
+ */
+/*
+ * Description      : Test Quantified Expressions
+ *                  : some <variable-name> in [ordered-list] satisfies function expression
+ *                  : some <variable-name> in [ordered-list],<variable-name> in [ordered-list] satisfies expression
+ * Expected Result  : Success
+ * Date             : 5th July 2012
+ */
+
+with  a as [some x in ['foo','foobar','foot','fox'] satisfies ("string-length"(x) = 3),some x in [[5,4,3,2],[1,2,3,4,5,6,7,8],[4,2,3,4]] satisfies (count(x) = 8),some x in [1,2] satisfies ((x = 1) or (x = 2)),some x in [1,2] satisfies ((x = 1) and ((x + 1) = 2)),some x in ['A','B','C'] satisfies (x = 'A'),some x in [1,2,3],
+y in [4,5,6] satisfies ((x + y) = 5),some x in [1,2,3],
+y in [4,5,6] satisfies ((x - y) = 5),some x in [1,2,3],
+y in [4,5,6] satisfies ((x * y) = 10),some x in [1,2,3],
+y in [4,5,6] satisfies ((x / y) = 2)]
+select element i
+from  a as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.1.ddl.sqlpp
new file mode 100644
index 0000000..546f4af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.1.ddl.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.
+ */
+/*
+ * Description      :  Test Quantified Expressions 
+ *                  :  some <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies function expression
+ * Expected Result  :  Success
+ * Date             :  5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.2.update.sqlpp
new file mode 100644
index 0000000..546f4af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.2.update.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.
+ */
+/*
+ * Description      :  Test Quantified Expressions 
+ *                  :  some <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies function expression
+ * Expected Result  :  Success
+ * Date             :  5th July 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.3.query.sqlpp
new file mode 100644
index 0000000..aa96f35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_05/somesat_05.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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      :  Test Quantified Expressions 
+ *                  :  some <variable-name> in [ordered-list], <variable-name> in [ordered-list] satisfies function expression
+ * Expected Result  :  Success
+ * Date             :  5th July 2012
+ */
+
+with  a as [some x in ['foo','foobar','footnote'],
+y in ['foofoo','fool','foolish','foot','foo'] satisfies (string(x) = string(y)),some x in ['1','2','3'],
+y in ['4','5','6'] satisfies (int32(x) = int32(y)),some x in ['1.1','2.2','3.3'],
+y in ['4.4','5.5','6.6'] satisfies (float(x) = float(y)),some x in ['1.1d','2.2d','3.3d'],
+y in ['4.4d','5.5d','6.6d'] satisfies (double(x) = double(y)),some x in ['true','false'],
+y in ['false','true'] satisfies (boolean(x) = boolean(y)),some x in ['1980-05-05T13:13:13Z','1980-05-05T13:13:13Z'],
+y in ['1980-05-05T13:13:13Z','1980-05-05T13:13:13Z'] satisfies (datetime(x) = datetime(y)),some x in ['1985-07-05Z','1985-07-05Z'],
+y in ['1985-07-05Z','1985-07-05Z'] satisfies (date(x) = date(y))]
+select element i
+from  a as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.1.ddl.sqlpp
new file mode 100644
index 0000000..828984a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.1.ddl.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.
+ */
+/*
+ * Description    : Tests that existential quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.2.update.sqlpp
new file mode 100644
index 0000000..c7daf77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.2.update.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.
+ */
+/*
+ * Description    : Tests that existential quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.3.query.sqlpp
new file mode 100644
index 0000000..a566e92
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/somesat_06/somesat_06.3.query.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.
+ */
+/*
+ * Description    : Tests that existential quantification returns true/false correctly.
+ * Success        : Yes
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  x as [some x in [false,false] satisfies x,some x in [true,false] satisfies x,some x in [false,true] satisfies x,some x in [true,true] satisfies x,some x in [false,false] satisfies test.not(x),some x in [true,false] satisfies test.not(x),some x in [false,true] satisfies test.not(x),some x in [true,true] satisfies test.not(x)]
+select element i
+from  x as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.1.ddl.sqlpp
new file mode 100644
index 0000000..308f472
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.2.ddl.sqlpp
new file mode 100644
index 0000000..04fb9ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.2.ddl.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 TinySocial;
+
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.3.update.sqlpp
new file mode 100644
index 0000000..656ee00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.3.update.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 TinySocial;
+
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.4.query.sqlpp
new file mode 100644
index 0000000..68dc4e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.4.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  TwitterUsers as user
+order by user."screen-name"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.1.ddl.sqlpp
new file mode 100644
index 0000000..308f472
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.2.ddl.sqlpp
new file mode 100644
index 0000000..04fb9ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.2.ddl.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 TinySocial;
+
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.3.update.sqlpp
new file mode 100644
index 0000000..656ee00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.3.update.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 TinySocial;
+
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.4.query.sqlpp
new file mode 100644
index 0000000..966a811
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.4.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  TwitterUsers as user
+order by user."screen-name" desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.1.ddl.sqlpp
new file mode 100644
index 0000000..308f472
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.1.ddl.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.2.ddl.sqlpp
new file mode 100644
index 0000000..04fb9ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.2.ddl.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 TinySocial;
+
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.3.update.sqlpp
new file mode 100644
index 0000000..656ee00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.3.update.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 TinySocial;
+
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.4.query.sqlpp
new file mode 100644
index 0000000..68dc4e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.4.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  TwitterUsers as user
+order by user."screen-name"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.5.query.sqlpp
new file mode 100644
index 0000000..966a811
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.5.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  TwitterUsers as user
+order by user."screen-name" desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.6.query.sqlpp
new file mode 100644
index 0000000..3e1dc79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.6.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  TwitterUsers as user
+order by user.friends_count
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.7.query.sqlpp
new file mode 100644
index 0000000..eb3fbe8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/range-hints/order-by/order-by.7.query.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.
+ */
+
+use TinySocial;
+
+
+select element user
+from  TwitterUsers as user
+order by user.friends_count desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/RecordsQueries.xml b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/RecordsQueries.xml
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/RecordsQueries.xml
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.1.ddl.sqlpp
new file mode 100644
index 0000000..ea84b90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.1.ddl.sqlpp
@@ -0,0 +1,88 @@
+/*
+ * 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  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+{
+  id : int64
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+ closed {
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+{
+  id : int64
+}
+
+create  table Animals(Animal) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.10.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.10.query.sqlpp
new file mode 100644
index 0000000..e203fa3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.10.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.11.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.11.query.sqlpp
new file mode 100644
index 0000000..15370d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.11.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.12.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.12.query.sqlpp
new file mode 100644
index 0000000..4610165
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.12.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.2.update.sqlpp
new file mode 100644
index 0000000..5e6258d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+load  table Animals using "localfs" (("path"="nc1://data/classifications/animals.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.3.query.sqlpp
new file mode 100644
index 0000000..7a07002
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.3.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower.lower.lower.lower.lower.lower.Species
+order by result
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.4.query.sqlpp
new file mode 100644
index 0000000..3f942b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.4.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower.lower.lower.lower.lower.lower
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.5.query.sqlpp
new file mode 100644
index 0000000..394d451
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.5.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower.lower.lower.lower.lower
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.6.query.sqlpp
new file mode 100644
index 0000000..a92a5e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.6.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower.lower.lower.lower
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.7.query.sqlpp
new file mode 100644
index 0000000..fd570dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.7.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower.lower.lower
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.8.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.8.query.sqlpp
new file mode 100644
index 0000000..e8eddae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.8.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower.lower
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.9.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.9.query.sqlpp
new file mode 100644
index 0000000..3e2e47b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/access-nested-fields/access-nested-fields.9.query.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.
+ */
+/*
+* Description  : Access a records nested records at each level.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test.class.fullClassification.lower
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.1.ddl.sqlpp
new file mode 100644
index 0000000..f4651ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Tests whether a conflict between two closed field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.2.update.sqlpp
new file mode 100644
index 0000000..f205e1a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.2.update.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.
+ */
+/*
+ * Description    : Tests whether a conflict between two closed field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.3.query.sqlpp
new file mode 100644
index 0000000..a7acd46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a conflict between two closed field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+use test;
+
+
+{'name':'john','name':'smith'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.3.query.sqlpp
new file mode 100644
index 0000000..f6a43ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.3.query.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;
+
+
+set "import-private-functions" "true";
+
+select element test."closed-record-constructor"('foo1',10,'bar1',20,'foo2',30,'bar2',40);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.3.query.sqlpp
new file mode 100644
index 0000000..0568127
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.3.query.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;
+
+
+set "import-private-functions" "true";
+
+select element test."closed-record-constructor"('foo1',10,'bar1',test."closed-record-constructor"('bar1.1',10,'bar1.2',20,'bar1.3',30,'bar1.4',test."closed-record-constructor"('bar1.4.1',10,'bar1.4.2',20,'bar1.4.3',30,'bar1.4.4',40),'foo2',30,'bar2',40),'foo2',30,'bar2',40);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.3.query.sqlpp
new file mode 100644
index 0000000..e6b8e5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.3.query.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;
+
+
+set "import-private-functions" "true";
+
+select element {'foo1':10,'bar1':{'bar1.1':10,'bar1.2':20,'bar1.3':30,'bar1.4':{'bar1.4.1':10,'bar1.4.2':20}},'foo2':30,'bar2':40};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.3.query.sqlpp
new file mode 100644
index 0000000..e175fc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/expFieldName/expFieldName.3.query.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 element {x:1}
+from  ['field1','field2'] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.3.query.sqlpp
new file mode 100644
index 0000000..d20c2bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-by-index_01/field-access-by-index_01.3.query.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;
+
+
+set "import-private-functions" "true";
+
+test."field-access-by-index"({'foo1':10,'bar1':20,'foo2':30,'bar2':40},test.int32('2'));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.1.ddl.sqlpp
new file mode 100644
index 0000000..025ec26
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests whether a field access on an open field (statically of type ANY) succeeds.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  name : string
+}
+
+create  table testds(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.2.update.sqlpp
new file mode 100644
index 0000000..85a1bfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a field access on an open field (statically of type ANY) succeeds.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':123,'name':'John Doe','address':{'zip':92617}};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.3.query.sqlpp
new file mode 100644
index 0000000..8daaddf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/field-access-on-open-field/field-access-on-open-field.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a field access on an open field (statically of type ANY) succeeds.
+ *                  Guards against regression to issue 207.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element a.zip
+from  testds as l
+with  a as l.address
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.1.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.1.query.sqlpp
new file mode 100644
index 0000000..de96a04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.1.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+"get-record-field-value"({'id':1,'project':'AsterixDB','address':{'city':'Irvine','state':'CA'},'related':['Hivestrix','Preglix','Apache VXQuery']},'project');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.2.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.2.query.sqlpp
new file mode 100644
index 0000000..2ef2b30
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.2.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+"get-record-field-value"({'id':1,'project':'AsterixDB','address':{'city':'Irvine','state':'CA'},'related':['Hivestrix','Preglix','Apache VXQuery']},'address');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.3.query.sqlpp
new file mode 100644
index 0000000..951adbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/documentation-example/documentation-example.3.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+"get-record-field-value"({'id':1,'project':'AsterixDB','address':{'city':'Irvine','state':'CA'},'related':['Hivestrix','Preglix','Apache VXQuery']},'related');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.1.ddl.sqlpp
new file mode 100644
index 0000000..719da3a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.1.ddl.sqlpp
@@ -0,0 +1,92 @@
+/*
+ * 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  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+ closed {
+  id : int64,
+  Species : string
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+ closed {
+  id : int64,
+  Family : string,
+  lower : GS
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+ closed {
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+ closed {
+  id : int64,
+  Kingdom : string,
+  lower : PCOFGS
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+ closed {
+  id : int64,
+  class : Classification
+}
+
+create  table Animals(Animal) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.2.update.sqlpp
new file mode 100644
index 0000000..057e0d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+load  table Animals using "localfs" (("path"="nc1://data/classifications/animals.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.3.query.sqlpp
new file mode 100644
index 0000000..8616dd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.3.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test."get-record-field-value"(test,'class')
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.1.ddl.sqlpp
new file mode 100644
index 0000000..43fac82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.1.ddl.sqlpp
@@ -0,0 +1,88 @@
+/*
+ * 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  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+{
+  id : int64
+}
+
+create type test.GS as
+ closed {
+  id : int64,
+  Genus : string,
+  lower : S
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+ closed {
+  id : int64,
+  "Order" : string,
+  lower : FGS
+}
+
+create type test.COFGS as
+{
+  id : int64,
+  Class : string,
+  lower : OFGS
+}
+
+create type test.PCOFGS as
+ closed {
+  id : int64,
+  Phylum : string,
+  lower : COFGS
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+ closed {
+  id : int64,
+  fullClassification : KPCOFGS
+}
+
+create type test.Animal as
+{
+  id : int64
+}
+
+create  table Animals(Animal) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.2.update.sqlpp
new file mode 100644
index 0000000..057e0d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+load  table Animals using "localfs" (("path"="nc1://data/classifications/animals.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.3.query.sqlpp
new file mode 100644
index 0000000..8616dd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.3.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test."get-record-field-value"(test,'class')
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.1.ddl.sqlpp
new file mode 100644
index 0000000..d1dca66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.1.ddl.sqlpp
@@ -0,0 +1,83 @@
+/*
+ * 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  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.S as
+{
+  id : int64
+}
+
+create type test.GS as
+{
+  id : int64,
+  Genus : string
+}
+
+create type test.FGS as
+{
+  id : int64,
+  Family : string
+}
+
+create type test.OFGS as
+{
+  id : int64,
+  "Order" : string
+}
+
+create type test.COFGS as
+{
+  id : int64,
+  Class : string
+}
+
+create type test.PCOFGS as
+{
+  id : int64,
+  Phylum : string
+}
+
+create type test.KPCOFGS as
+{
+  id : int64,
+  Kingdom : string
+}
+
+create type test.Classification as
+{
+  id : int64
+}
+
+create type test.Animal as
+{
+  id : int64
+}
+
+create  table Animals(Animal) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.2.update.sqlpp
new file mode 100644
index 0000000..057e0d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+load  table Animals using "localfs" (("path"="nc1://data/classifications/animals.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.3.query.sqlpp
new file mode 100644
index 0000000..8616dd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.3.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use test;
+
+
+select element result
+from  Animals as test
+with  result as test."get-record-field-value"(test,'class')
+order by result.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.1.ddl.sqlpp
new file mode 100644
index 0000000..5a70a09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.1.ddl.sqlpp
@@ -0,0 +1,76 @@
+/*
+ * 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  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type TinySocial.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.2.ddl.sqlpp
new file mode 100644
index 0000000..5e860d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.2.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.3.update.sqlpp
new file mode 100644
index 0000000..607e3ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.3.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.4.query.sqlpp
new file mode 100644
index 0000000..ee7c608
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.4.query.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.
+ */
+/*
+* Description  : Testing get-record-field-value under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element result
+from  TweetMessages as r,
+      TinySocial."get-record-fields"(r) as f
+with  result as TinySocial."get-record-field-value"(r,f."field-name")
+where (f."field-type" = 'STRING')
+order by result
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/documentation-example/documentation-example.1.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/documentation-example/documentation-example.1.query.sqlpp
new file mode 100644
index 0000000..ba59485
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/documentation-example/documentation-example.1.query.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.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+"get-record-fields"({'id':1,'project':'AsterixDB','address':{'city':'Irvine','state':'CA'},'related':['Hivestrix','Preglix','Apache VXQuery']});
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.1.ddl.sqlpp
new file mode 100644
index 0000000..3a404a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.1.ddl.sqlpp
@@ -0,0 +1,114 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type TinySocial.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
+create type TinySocial.TwitterUserAlternateType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageAlternateType as
+ closed {
+  tweetid : string,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentAlternateType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserAlternateType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime
+}
+
+create type TinySocial.FacebookMessageAlternateType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.2.ddl.sqlpp
new file mode 100644
index 0000000..7af03e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.2.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
+create  table FacebookUsersAlternate(FacebookUserAlternateType) primary key id;
+
+create  table FacebookMessagesAlternate(FacebookMessageAlternateType) primary key "message-id";
+
+create  table TwitterUsersAlternate(TwitterUserAlternateType) primary key "screen-name";
+
+create  table TweetMessagesAlternate(TweetMessageAlternateType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.3.update.sqlpp
new file mode 100644
index 0000000..0f40098
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.3.update.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
+insert into TwitterUsersAlternate
+select element {'screen-name':r."screen-name",'lang':r.lang,'friends_count':r.friends_count,'statuses_count':r.statuses_count}
+from  TwitterUsers as r
+;
+insert into TweetMessagesAlternate
+select element {'tweetid':r.tweetid,'sender-location':r."sender-location",'send-time':r."send-time",'message-text':r."message-text"}
+from  TweetMessages as r
+;
+insert into FacebookUsersAlternate
+select element {'id':r.id,'alias':r.alias,'name':r.name,'user-since':r."user-since"}
+from  FacebookUsers as r
+;
+insert into FacebookMessagesAlternate
+select element {'message-id':r."message-id",'author-id':r."author-id",'in-response-to':r."in-response-to",'sender-location':r."sender-location",'message':r.message}
+from  FacebookMessages as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.4.query.sqlpp
new file mode 100644
index 0000000..31b398c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.4.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(user)
+from  FacebookUsersAlternate as user
+where (user.id = 8)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.5.query.sqlpp
new file mode 100644
index 0000000..d94fdf3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.5.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookUsersAlternate as r
+order by r.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.6.query.sqlpp
new file mode 100644
index 0000000..311b1ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.6.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookMessagesAlternate as r
+order by r."message-id"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.7.query.sqlpp
new file mode 100644
index 0000000..5398032
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.7.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TwitterUsersAlternate as r
+order by r."screen-name"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.8.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.8.query.sqlpp
new file mode 100644
index 0000000..ebaebae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.8.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TweetMessagesAlternate as r
+order by r.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.9.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.9.query.sqlpp
new file mode 100644
index 0000000..1e06e49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.9.query.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.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element {'field-name':n,'field-type':t,'count':count}
+from  TweetMessagesAlternate as r,
+      TinySocial."get-record-fields"(r) as f
+group by f."field-name" as n,f."field-type" as t
+with  count as TinySocial.count(r)
+order by n,t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.1.ddl.sqlpp
new file mode 100644
index 0000000..7514ab1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.1.ddl.sqlpp
@@ -0,0 +1,116 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type TinySocial.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
+create type TinySocial.TwitterUserAlternateType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageAlternateType as
+ closed {
+  tweetid : string,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentAlternateType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserAlternateType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "friend-ids" : {{int64}},
+  "user-since" : datetime
+}
+
+create type TinySocial.FacebookMessageAlternateType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.2.ddl.sqlpp
new file mode 100644
index 0000000..7af03e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.2.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
+create  table FacebookUsersAlternate(FacebookUserAlternateType) primary key id;
+
+create  table FacebookMessagesAlternate(FacebookMessageAlternateType) primary key "message-id";
+
+create  table TwitterUsersAlternate(TwitterUserAlternateType) primary key "screen-name";
+
+create  table TweetMessagesAlternate(TweetMessageAlternateType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.3.update.sqlpp
new file mode 100644
index 0000000..3285080
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.3.update.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
+insert into TwitterUsersAlternate
+select element {'screen-name':r."screen-name",'lang':r.lang,'friends_count':r.friends_count,'statuses_count':r.statuses_count}
+from  TwitterUsers as r
+;
+insert into TweetMessagesAlternate
+select element {'tweetid':r.tweetid,'sender-location':r."sender-location",'send-time':r."send-time",'message-text':r."message-text",'referred-topics':r."referred-topics"}
+from  TweetMessages as r
+;
+insert into FacebookUsersAlternate
+select element {'id':r.id,'alias':r.alias,'name':r.name,'friend-ids':r."friend-ids",'user-since':r."user-since"}
+from  FacebookUsers as r
+;
+insert into FacebookMessagesAlternate
+select element {'message-id':r."message-id",'author-id':r."author-id",'in-response-to':r."in-response-to",'sender-location':r."sender-location",'message':r.message}
+from  FacebookMessages as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.4.query.sqlpp
new file mode 100644
index 0000000..31b398c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.4.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(user)
+from  FacebookUsersAlternate as user
+where (user.id = 8)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.5.query.sqlpp
new file mode 100644
index 0000000..d94fdf3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.5.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookUsersAlternate as r
+order by r.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.6.query.sqlpp
new file mode 100644
index 0000000..311b1ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.6.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookMessagesAlternate as r
+order by r."message-id"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.7.query.sqlpp
new file mode 100644
index 0000000..5398032
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.7.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TwitterUsersAlternate as r
+order by r."screen-name"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.8.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.8.query.sqlpp
new file mode 100644
index 0000000..ebaebae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.8.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TweetMessagesAlternate as r
+order by r.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.9.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.9.query.sqlpp
new file mode 100644
index 0000000..1e06e49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.9.query.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.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element {'field-name':n,'field-type':t,'count':count}
+from  TweetMessagesAlternate as r,
+      TinySocial."get-record-fields"(r) as f
+group by f."field-name" as n,f."field-type" as t
+with  count as TinySocial.count(r)
+order by n,t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.1.ddl.sqlpp
new file mode 100644
index 0000000..de4eb14
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.1.ddl.sqlpp
@@ -0,0 +1,116 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type TinySocial.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
+create type TinySocial.TwitterUserAlternateType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageAlternateType as
+ closed {
+  tweetid : string,
+  user : TwitterUserAlternateType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentAlternateType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserAlternateType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  employment : EmploymentAlternateType
+}
+
+create type TinySocial.FacebookMessageAlternateType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.2.ddl.sqlpp
new file mode 100644
index 0000000..7af03e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.2.ddl.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
+create  table FacebookUsersAlternate(FacebookUserAlternateType) primary key id;
+
+create  table FacebookMessagesAlternate(FacebookMessageAlternateType) primary key "message-id";
+
+create  table TwitterUsersAlternate(TwitterUserAlternateType) primary key "screen-name";
+
+create  table TweetMessagesAlternate(TweetMessageAlternateType) primary key tweetid;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.3.update.sqlpp
new file mode 100644
index 0000000..3f49fe7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.3.update.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
+insert into TwitterUsersAlternate
+select element {'screen-name':r."screen-name",'lang':r.lang,'friends_count':r.friends_count,'statuses_count':r.statuses_count}
+from  TwitterUsers as r
+;
+insert into TweetMessagesAlternate
+select element {'tweetid':r.tweetid,'user':r.user,'sender-location':r."sender-location",'send-time':r."send-time",'message-text':r."message-text"}
+from  TweetMessages as r
+;
+insert into FacebookUsersAlternate
+select element {'id':r.id,'alias':r.alias,'name':r.name,'user-since':r."user-since",'employment':r.employment[0]}
+from  FacebookUsers as r
+;
+insert into FacebookMessagesAlternate
+select element {'message-id':r."message-id",'author-id':r."author-id",'in-response-to':r."in-response-to",'sender-location':r."sender-location",'message':r.message}
+from  FacebookMessages as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.4.query.sqlpp
new file mode 100644
index 0000000..31b398c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.4.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(user)
+from  FacebookUsersAlternate as user
+where (user.id = 8)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.5.query.sqlpp
new file mode 100644
index 0000000..d94fdf3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.5.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookUsersAlternate as r
+order by r.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.6.query.sqlpp
new file mode 100644
index 0000000..311b1ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.6.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookMessagesAlternate as r
+order by r."message-id"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.7.query.sqlpp
new file mode 100644
index 0000000..5398032
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.7.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TwitterUsersAlternate as r
+order by r."screen-name"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.8.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.8.query.sqlpp
new file mode 100644
index 0000000..ebaebae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.8.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TweetMessagesAlternate as r
+order by r.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.9.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.9.query.sqlpp
new file mode 100644
index 0000000..1e06e49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.9.query.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.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element {'field-name':n,'field-type':t,'count':count}
+from  TweetMessagesAlternate as r,
+      TinySocial."get-record-fields"(r) as f
+group by f."field-name" as n,f."field-type" as t
+with  count as TinySocial.count(r)
+order by n,t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.1.ddl.sqlpp
new file mode 100644
index 0000000..08f46fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type TinySocial.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.2.ddl.sqlpp
new file mode 100644
index 0000000..30b2404
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.2.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.3.update.sqlpp
new file mode 100644
index 0000000..b74464d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.3.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.4.query.sqlpp
new file mode 100644
index 0000000..6b6a4f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.4.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(user)
+from  FacebookUsers as user
+where (user.id = 8)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.5.query.sqlpp
new file mode 100644
index 0000000..4ec7e5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.5.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookUsers as r
+order by r.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.6.query.sqlpp
new file mode 100644
index 0000000..602a608
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.6.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  FacebookMessages as r
+order by r."message-id"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.7.query.sqlpp
new file mode 100644
index 0000000..103e998
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.7.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TwitterUsers as r
+order by r."screen-name"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.8.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.8.query.sqlpp
new file mode 100644
index 0000000..dfab7dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.8.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element TinySocial."get-record-fields"(r)
+from  TweetMessages as r
+order by r.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.9.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.9.query.sqlpp
new file mode 100644
index 0000000..0889e34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/get-record-fields/tiny-social-example/tiny-social-example.9.query.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.
+ */
+/*
+* Description  : Testing get-record-fields under different queries.
+* Expected Res : Success
+* Date         : 04 Jun 2015
+*/
+
+use TinySocial;
+
+
+select element {'field-name':n,'field-type':t,'count':count}
+from  TweetMessages as r,
+      TinySocial."get-record-fields"(r) as f
+group by f."field-name" as n,f."field-type" as t
+with  count as TinySocial.count(r)
+order by n,t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.1.ddl.sqlpp
new file mode 100644
index 0000000..81990a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests whether a conflict between an open and closed field name are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.opentype as
+{
+  id : int32,
+  fname : string
+}
+
+create  table testds(opentype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.2.update.sqlpp
new file mode 100644
index 0000000..9d49950
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a conflict between an open and closed field name are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':1,'fname':'name'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.3.query.sqlpp
new file mode 100644
index 0000000..f15d2d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a conflict between an open and closed field name are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+use test;
+
+
+select element {x.fname:'smith',test.lowercase('NAME'):'john'}
+from  testds as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.1.ddl.sqlpp
new file mode 100644
index 0000000..2145aeb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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    : Tests whether a conflict between two open field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.opentype as
+{
+  fname1 : string,
+  fname2 : string
+}
+
+create  table testds(opentype) primary key fname1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.2.update.sqlpp
new file mode 100644
index 0000000..28cf025
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a conflict between two open field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+use test;
+
+
+insert into testds
+select element {'fname1':'name','fname2':'name'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.3.query.sqlpp
new file mode 100644
index 0000000..b83b673
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests whether a conflict between two open field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+use test;
+
+
+select element {x.fname1:'john',x.fname2:'smith'}
+from  testds as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.3.query.sqlpp
new file mode 100644
index 0000000..158f480
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_01/open-record-constructor_01.3.query.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;
+
+
+set "import-private-functions" "true";
+
+select element test."open-record-constructor"('foo1',10,'bar1',20,'foo2',30,'bar2',40);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.3.query.sqlpp
new file mode 100644
index 0000000..0ca8b9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/records/open-record-constructor_02/open-record-constructor_02.3.query.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;
+
+
+set "import-private-functions" "true";
+
+select element test."open-record-constructor"('foo1',10,'bar1',test."closed-record-constructor"('bar1.1',10,'bar1.2',20,'bar1.3',30,'bar1.4',test."closed-record-constructor"('bar1.4.1',10,'bar1.4.2',20,'bar1.4.3',30,'bar1.4.4',40),'foo2',30,'bar2',40),'foo2',30,'bar2',40);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.1.ddl.sqlpp
new file mode 100644
index 0000000..5d6bc7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.1.ddl.sqlpp
@@ -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.
+ */
+/* scan and print a delimited text file */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP1(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.2.update.sqlpp
new file mode 100644
index 0000000..e833ac1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.2.update.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.
+ */
+/* scan and print a delimited text file */
+
+use test;
+
+
+load  table DBLP1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.3.query.sqlpp
new file mode 100644
index 0000000..02f8073
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/10/10.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/* scan and print a delimited text file */
+
+use test;
+
+
+select element paper
+from  DBLP1 as paper
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.1.ddl.sqlpp
new file mode 100644
index 0000000..ee20e66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.1.ddl.sqlpp
@@ -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.
+ */
+/* scan and print an ADM file as a dataset of closed records */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLPadm(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.2.update.sqlpp
new file mode 100644
index 0000000..3d8391e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.2.update.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.
+ */
+/* scan and print an ADM file as a dataset of closed records */
+
+use test;
+
+
+load  table DBLPadm using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.3.query.sqlpp
new file mode 100644
index 0000000..4ed245f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/20/20.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/* scan and print an ADM file as a dataset of closed records */
+
+use test;
+
+
+select element paper
+from  DBLPadm as paper
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.1.ddl.sqlpp
new file mode 100644
index 0000000..8f4e080
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.1.ddl.sqlpp
@@ -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.
+ */
+/* scan and print 2 ADM file splits as an external dataset of closed records */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create external  table DBLPsplits(DBLPType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/dblp-small/dblp-small.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.2.update.sqlpp
new file mode 100644
index 0000000..414a3ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.2.update.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.
+ */
+/* scan and print 2 ADM file splits as an external dataset of closed records */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.3.query.sqlpp
new file mode 100644
index 0000000..2a6ecb2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/30/30.3.query.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.
+ */
+/* scan and print 2 ADM file splits as an external dataset of closed records */
+
+use test;
+
+
+select element paper
+from  DBLPsplits as paper
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.1.ddl.sqlpp
new file mode 100644
index 0000000..2f99a00
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.1.ddl.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.AllType as
+{
+  id : int64,
+  string : string,
+  float : float,
+  double : double,
+  boolean : boolean,
+  int8 : int8,
+  int16 : int16,
+  int32 : int32,
+  int64 : int64,
+  unorderedList : {{string}},
+  orderedList : [string],
+  record : AddressType,
+  date : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  point : point,
+  point3d : point3d,
+  line : line,
+  rectangle : rectangle,
+  polygon : polygon,
+  circle : circle,
+  binary : binary,
+  uuid : uuid
+}
+
+create external  table "All"(AllType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/allData.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.3.query.sqlpp
new file mode 100644
index 0000000..dc5c8cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_01/alltypes_01.3.query.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 element a
+from  "All" as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02.sqlpp
new file mode 100644
index 0000000..3d655a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02.sqlpp
@@ -0,0 +1,65 @@
+/*
+ * 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  : Test variant syntax for dataset access (scan)
+ *              : using parentheses and quotes is optional
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int32,
+  street : string,
+  city : string
+}
+
+create type test.AllType as
+{
+  id : int32,
+  name : string,
+  age : float,
+  salary : double,
+  married : boolean,
+  interests : {{string}},
+  children : [string],
+  address : AddressType,
+  dob : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  location2d : point,
+  location3d : point3d,
+  line : line,
+  polygon : polygon,
+  circle : circle
+}
+
+create external  table "All"(AllType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/allData.json"),("format"="adm"));
+
+write output to nc1:"rttest/scan_alltypes_02.adm"
+select element a
+from  "All" as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.1.ddl.sqlpp
new file mode 100644
index 0000000..8c63fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.1.ddl.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test variant syntax for dataset access (scan)
+ *              : using parentheses and quotes is optional
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.AllType as
+{
+  id : int64,
+  string : string,
+  float : float,
+  double : double,
+  boolean : boolean,
+  int8 : int8,
+  int16 : int16,
+  int32 : int32,
+  int64 : int64,
+  unorderedList : {{string}},
+  orderedList : [string],
+  record : AddressType,
+  date : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  point : point,
+  point3d : point3d,
+  line : line,
+  rectangle : rectangle,
+  polygon : polygon,
+  circle : circle,
+  binary : binary,
+  uuid : uuid
+}
+
+create external  table "All"(AllType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/allData.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.2.update.sqlpp
new file mode 100644
index 0000000..0ca14b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.2.update.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.
+ */
+/*
+ * Description  : Test variant syntax for dataset access (scan)
+ *              : using parentheses and quotes is optional
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.3.query.sqlpp
new file mode 100644
index 0000000..77c5a24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/alltypes_02/alltypes_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Test variant syntax for dataset access (scan)
+ *              : using parentheses and quotes is optional
+ * Expected Res : Success
+ * Date         : 6th March 2013
+ */
+
+use test;
+
+
+select element a
+from  "All" as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax.sqlpp
new file mode 100644
index 0000000..ee0500c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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    : Tests syntax error for the changed dataset access syntax
+ * Expected Result: Syntax Error from parser
+ * Date: 			March 6th 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Employee as
+ closed {
+  id : int32,
+  name : string,
+  salary : int32
+}
+
+create  table Office(Employee) primary key id;
+
+insert into Office
+select element {'id':1,'name':'clerk#1','salary':120000};
+select element t
+from  "test.Office" as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.1.ddl.sqlpp
new file mode 100644
index 0000000..81fdf4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.1.ddl.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.
+ */
+/*
+ * Description    : Tests syntax error for the changed dataset access syntax
+ * Expected Result: Syntax Error from parser
+ * Date: 			March 6th 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Employee as
+ closed {
+  id : int32,
+  name : string,
+  salary : int32
+}
+
+create  table Office(Employee) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.2.update.sqlpp
new file mode 100644
index 0000000..409e19c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests syntax error for the changed dataset access syntax
+ * Expected Result: Syntax Error from parser
+ * Date: 			March 6th 2013
+ */
+
+use test;
+
+
+insert into Office
+select element {'id':1,'name':'clerk#1','salary':120000};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.3.query.sqlpp
new file mode 100644
index 0000000..fc65160
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Tests syntax error for the changed dataset access syntax
+ * Expected Result: Syntax Error from parser
+ * Date: 			March 6th 2013
+ */
+
+use test;
+
+
+select element t
+from  "test.Office" as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.1.ddl.sqlpp
new file mode 100644
index 0000000..2f65563
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Create an  dataset and load it from two file splits
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLPadm(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.2.update.sqlpp
new file mode 100644
index 0000000..2186211
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.2.update.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.
+ */
+/*
+* Description  : Create an  dataset and load it from two file splits 
+
+use test;
+
+
+load  table DBLPadm using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/part-00000.adm, nc1://data/dblp-small/part-00001.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.3.query.sqlpp
new file mode 100644
index 0000000..453305f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_1/issue238_query_1.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an  dataset and load it from two file splits 
+
+use test;
+
+
+select element paper
+from  DBLPadm as paper
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.1.ddl.sqlpp
new file mode 100644
index 0000000..2f65563
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : Create an  dataset and load it from two file splits
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLPadm(DBLPType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.2.update.sqlpp
new file mode 100644
index 0000000..d7618b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.2.update.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.
+ */
+/*
+* Description  : Create an  dataset and load it from two file splits 
+
+use test;
+
+
+load  table DBLPadm using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/part-00000.adm, \n nc1://data/dblp-small/part-00001.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.3.query.sqlpp
new file mode 100644
index 0000000..453305f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/issue238_query_2/issue238_query_2.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Description  : Create an  dataset and load it from two file splits 
+
+use test;
+
+
+select element paper
+from  DBLPadm as paper
+order by paper.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.1.ddl.sqlpp
new file mode 100644
index 0000000..cb1bdad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.NumericType as
+{
+  id : int64,
+  int8Field : int8?,
+  int16Field : int16?,
+  int32Field : int32?,
+  int64Field : int64?,
+  floatField : float?,
+  doubleField : double?
+}
+
+create external  table Numeric(NumericType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/numericData.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.3.query.sqlpp
new file mode 100644
index 0000000..25b91a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/numeric_types_01/numeric_types_01.3.query.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 element a
+from  Numeric as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.1.ddl.sqlpp
new file mode 100644
index 0000000..a845209
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.SpatialType as
+{
+  id : int64,
+  point : point,
+  point3d : point3d,
+  line : line,
+  polygon : polygon,
+  circle : circle
+}
+
+create external  table Spatial(SpatialType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.2.update.sqlpp
new file mode 100644
index 0000000..3d46965
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.2.update.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.3.query.sqlpp
new file mode 100644
index 0000000..d4360d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_01/spatial_types_01.3.query.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 element a
+from  Spatial as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.1.ddl.sqlpp
new file mode 100644
index 0000000..79dfcb2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.SpatialType as
+{
+  id : int32,
+  point : point,
+  point3d : point3d,
+  line : line,
+  polygon : polygon,
+  circle : circle
+}
+
+create  table Spatial2(SpatialType) primary key id;
+
+load  table Spatial2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/spatialData.txt"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.3.query.sqlpp
new file mode 100644
index 0000000..35fec85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/spatial_types_02/spatial_types_02.3.query.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 element a
+from  Spatial2 as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.1.ddl.sqlpp
new file mode 100644
index 0000000..f5c83ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TempType as
+{
+  id : int64,
+  date : date,
+  time : time,
+  datetime : datetime,
+  duration : duration
+}
+
+create external  table Temp(TempType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/nontagged/tempData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.3.query.sqlpp
new file mode 100644
index 0000000..1c86988
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_01/temp_types_01.3.query.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 element a
+from  Temp as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.1.ddl.sqlpp
new file mode 100644
index 0000000..5e9e7d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.1.ddl.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TempType as
+ closed {
+  id : int32,
+  date : date,
+  time : time,
+  datetime : datetime,
+  duration : duration
+}
+
+create  table Temp2(TempType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.2.update.sqlpp
new file mode 100644
index 0000000..cd52d33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.2.update.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;
+
+
+load  table Temp2 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/nontagged/tempData.txt"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.3.query.sqlpp
new file mode 100644
index 0000000..5231c19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/scan/temp_types_02/temp_types_02.3.query.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 element a
+from  Temp2 as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.1.ddl.sqlpp
new file mode 100644
index 0000000..b2b8a08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/semistructured/tiny01/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.3.query.sqlpp
new file mode 100644
index 0000000..b2d8f6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/count-nullable/count-nullable.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'custage':age,'count':test.count(c)}
+from  Customers as c
+group by c.age as age
+order by age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.1.ddl.sqlpp
new file mode 100644
index 0000000..b2b8a08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.AddressType as
+{
+  number : int64,
+  street : string,
+  city : string
+}
+
+create type test.CustomerType as
+{
+  cid : int64,
+  name : string,
+  age : int64?,
+  address : AddressType?,
+  interests : {{string}},
+  children : [{
+          name : string,
+          age : int64?
+      }
+]
+}
+
+create external  table Customers(CustomerType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/semistructured/tiny01/customer.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.3.query.sqlpp
new file mode 100644
index 0000000..7d14a4d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/cust-filter/cust-filter.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'custname':c.name,'custage':c.age}
+from  Customers as c
+where (c.age < 21)
+order by c.cid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.1.ddl.sqlpp
new file mode 100644
index 0000000..068ca21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.OrderType as
+{
+  oid : int64,
+  cid : int64,
+  orderstatus : string,
+  orderpriority : string,
+  clerk : string,
+  total : float
+}
+
+create external  table Orders(OrderType) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/semistructured/tiny01/orders.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp
new file mode 100644
index 0000000..ba8ebd4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element o
+from  Orders as o
+where test.not(test."is-null"(o.param1))
+order by o.oid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.3.query.sqlpp
new file mode 100644
index 0000000..b209251
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+with  a as [1,2,3,4,5,6,7],
+      b as [1,3,4,5,7,8],
+      results as [test."edit-distance-check"(a,b,3),test."edit-distance-check"(b,a,3),test."edit-distance-check"(a,b,2),test."edit-distance-check"(b,a,2)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.3.query.sqlpp
new file mode 100644
index 0000000..3a38b58
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+with  a as 'Nalini Venkatasubramanian',
+      b as 'Nalini Wekatasupramanian',
+      results as [test."edit-distance-check"(a,b,3),test."edit-distance-check"(b,a,3),test."edit-distance-check"(a,b,2),test."edit-distance-check"(b,a,2)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.3.query.sqlpp
new file mode 100644
index 0000000..7c5cdf1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+with  a as '사랑',
+      b as '사랑해',
+      c as '사과',
+      results as [test."edit-distance-check"(a,b,1),test."edit-distance-check"(b,a,1),test."edit-distance-check"(b,c,1),test."edit-distance-check"(c,b,2)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.sqlpp
new file mode 100644
index 0000000..26a4579
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as [1,2,3,4,5,6,7,8,9,10],
+      results as [test."edit-distance-list-is-filterable"(a,0),test."edit-distance-list-is-filterable"(a,3),test."edit-distance-list-is-filterable"(b,0),test."edit-distance-list-is-filterable"(b,3),test."edit-distance-list-is-filterable"(b,8),test."edit-distance-list-is-filterable"(b,11)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.sqlpp
new file mode 100644
index 0000000..9636fe4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as '',
+      b as 'abcdefghij',
+      results as [test."edit-distance-string-is-filterable"(a,0,2,false),test."edit-distance-string-is-filterable"(a,0,2,true),test."edit-distance-string-is-filterable"(a,1,2,false),test."edit-distance-string-is-filterable"(a,1,2,true),test."edit-distance-string-is-filterable"(b,0,2,false),test."edit-distance-string-is-filterable"(b,0,2,true),test."edit-distance-string-is-filterable"(b,1,2,false),test."edit-distance-string-is-filterable"(b,1,2,true),test."edit-distance-string-is-filterable"(b,4,2,false),test."edit-distance-string-is-filterable"(b,5,2,true),test."edit-distance-string-is-filterable"(b,5,2,false),test."edit-distance-string-is-filterable"(b,6,2,true),test."edit-distance-string-is-filterable"(b,0,3,false),test."edit-distance-string-is-filterable"(b,0,3,true),test."edit-distance-string-is-filterable"(b,1,3,false),test."edit-distance-string-is-filterable"(b,1,3,true),test."edit-distance-string-is-filterable"(b,2,3,false),test."edit-distance-string-is-filterable"(b,3,3,true),test."edit-distance-string-is-filterable"(b,3,3,false),test."edit-distance-string-is-filterable"(b,4,3,true)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.3.query.sqlpp
new file mode 100644
index 0000000..e168982
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_ints/edit-distance_ints.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+with  a as [1,2,3,4,5,6,7],
+      b as [1,3,4,5,7,8],
+      results as [test."edit-distance"(a,b),test."edit-distance"(b,a)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.3.query.sqlpp
new file mode 100644
index 0000000..c092527
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/edit-distance_strings/edit-distance_strings.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+with  a as 'Nalini Venkatasubramanian',
+      b as 'Nalini Wekatasupramanian',
+      results as [test."edit-distance"(a,b),test."edit-distance"(b,a)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.3.query.sqlpp
new file mode 100644
index 0000000..a18b6c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "simfunction" "edit-distance";
+
+set "simthreshold" "2";
+
+select element paper
+from  DBLP as paper
+where (paper.authors ~= 'Amihay Motro')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.3.query.sqlpp
new file mode 100644
index 0000000..c529593
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.5f";
+
+select element paper
+from  DBLP as paper
+where (test."word-tokens"(paper.title) ~= test."word-tokens"('Transactions for Cooperative Environments'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.sqlpp
new file mode 100644
index 0000000..59192923
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element [test."prefix-len-jaccard"(5,0.800000f),test."prefix-len-jaccard"(5,0.900000f),test."prefix-len-jaccard"(10,0.800000f),test."prefix-len-jaccard"(10,0.900000f),test."prefix-len-jaccard"(15,0.800000f),test."prefix-len-jaccard"(15,0.900000f)]
+from  [1] as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.3.query.sqlpp
new file mode 100644
index 0000000..a3b6687
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.3.query.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.
+ */
+
+use test;
+
+
+with  a as [],
+      b as [1,2,3,4,5],
+      c as [4,3,5,8,9,2,1],
+      d as [7,5,8,9,3,10,1,2,11,4],
+      e as [11,12,13,14,15,16,17,18,19,20,21],
+      f as [1,2,3,4,5,7,8,9,10,11],
+      results as [test."similarity-jaccard-check"(a,b,0.000000f),test."similarity-jaccard-check"(b,a,0.000000f),test."similarity-jaccard-check"(a,b,0.100000f),test."similarity-jaccard-check"(b,a,0.100000f),test."similarity-jaccard-check"(c,d,0.600000f),test."similarity-jaccard-check"(d,c,0.600000f),test."similarity-jaccard-check"(c,d,0.800000f),test."similarity-jaccard-check"(d,c,0.800000f),test."similarity-jaccard-check"(e,f,0.050000f),test."similarity-jaccard-check"(f,e,0.050000f),test."similarity-jaccard-check"(e,f,0.800000f),test."similarity-jaccard-check"(f,e,0.800000f)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.3.query.sqlpp
new file mode 100644
index 0000000..2f41c34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element paper
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Environments for Cooperative Transactions'),
+      jacc as test."similarity-jaccard-check"(paper_tokens,query_tokens,0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.3.query.sqlpp
new file mode 100644
index 0000000..231330b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.3.query.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.
+ */
+
+use test;
+
+
+with  a as [],
+      b as ['abc','bcd','cde','def','efg'],
+      c as ['efg','abc','cde','def','hij','ijk','bcd'],
+      d as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      e as ['Efg','aBc','cdE','DEf','hIJ','IjK','BCD'],
+      f as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      g as ['cde','zza','zzb','zzc','zwz','za','zbe','zer','zba','zfe','wab'],
+      h as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      results as [test."similarity-jaccard-check"(a,b,0.000000f),test."similarity-jaccard-check"(b,a,0.000000f),test."similarity-jaccard-check"(a,b,0.100000f),test."similarity-jaccard-check"(b,a,0.100000f),test."similarity-jaccard-check"(c,d,0.600000f),test."similarity-jaccard-check"(d,c,0.600000f),test."similarity-jaccard-check"(c,d,0.800000f),test."similarity-jaccard-check"(d,c,0.800000f),test."similarity-jaccard-check"(e,f,0.600000f),test."similarity-jaccard-check"(f,e,0.600000f),test."similarity-jaccard-check"(e,f,0.800000f),test."similarity-jaccard-check"(f,e,0.800000f),test."similarity-jaccard-check"(g,h,0.050000f),test."similarity-jaccard-check"(h,g,0.050000f),test."similarity-jaccard-check"(g,h,0.800000f),test."similarity-jaccard-check"(h,g,0.800000f)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.3.query.sqlpp
new file mode 100644
index 0000000..27f0f63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.3.query.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.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  v1 as ['query','processing','in','multidatabase','systems'],
+      v2 as ['query','processing','in','object','oriented','database','systems'],
+      v3 as ['dynamic','query','optimization','and','query','processing','in','multidatabase','systems','1'],
+      v4 as ['transaction','management','in','multidatabase','systems'],
+      v5 as ['overview','of','multidatabase','transaction','management'],
+      results as [test."similarity-jaccard-check"(v1,v2,0.500000f),test."similarity-jaccard-check"(v1,v3,0.500000f),test."similarity-jaccard-check"(v4,v5,0.500000f)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.sqlpp
new file mode 100644
index 0000000..913e112
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element [test."similarity-jaccard-prefix-check"(3,[1,2,3],3,[1,2,3],1,1.000000f),test."similarity-jaccard-prefix-check"(3,[1,2,3],3,[1,2,4],1,0.500000f),test."similarity-jaccard-prefix-check"(3,[1,2,3],3,[1,2,4],1,0.600000f),test."similarity-jaccard-prefix-check"(3,[1,2,3],9,[1,2,3],1,0.500000f),test."similarity-jaccard-prefix-check"(4,[1,2,3,4],2,[1,2],1,0.500000f),test."similarity-jaccard-prefix-check"(4,[1,2,3,4],4,[1,2],1,0.330000f)]
+from  [1] as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.sqlpp
new file mode 100644
index 0000000..337bd21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element [test."similarity-jaccard-prefix"(3,[1,2,3],3,[1,2,3],1,1.000000f),test."similarity-jaccard-prefix"(3,[1,2,3],3,[1,2,4],1,0.500000f),test."similarity-jaccard-prefix"(3,[1,2,3],3,[1,2,4],1,0.600000f),test."similarity-jaccard-prefix"(3,[1,2,3],9,[1,2,3],1,0.500000f),test."similarity-jaccard-prefix"(4,[1,2,3,4],2,[1,2],1,0.500000f),test."similarity-jaccard-prefix"(4,[1,2,3,4],4,[1,2],1,0.330000f)]
+from  [1] as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.sqlpp
new file mode 100644
index 0000000..6a656fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.query.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.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as [1,2,3,4,5],
+      c as [1,2,3,4,5,8,9],
+      d as [1,2,3,4,5,7,8,9,10,11],
+      results as [test."similarity-jaccard-sorted-check"(a,b,0.000000f),test."similarity-jaccard-sorted-check"(b,a,0.000000f),test."similarity-jaccard-sorted-check"(a,b,0.100000f),test."similarity-jaccard-sorted-check"(b,a,0.100000f),test."similarity-jaccard-sorted-check"(c,d,0.600000f),test."similarity-jaccard-sorted-check"(d,c,0.600000f),test."similarity-jaccard-sorted-check"(c,d,0.800000f),test."similarity-jaccard-sorted-check"(d,c,0.800000f)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.1.ddl.sqlpp
new file mode 100644
index 0000000..97714cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.1.ddl.sqlpp
@@ -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.
+ */
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.sqlpp
new file mode 100644
index 0000000..7f02823
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element paper
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Cooperative Transactions for Environments'),
+      jacc as test."similarity-jaccard-sorted-check"(paper_tokens,query_tokens,0.500000f)
+where jacc[0]
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.sqlpp
new file mode 100644
index 0000000..084d005
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.query.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.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as ['abc','bcd','cde','def','efg'],
+      c as ['abc','bcd','cde','def','efg','hij','ijk'],
+      d as ['abc','bcd','cde','def','efg','fgh','ghi','hij','ijk','jkl'],
+      e as ['Abc','bCd','cdE','DEf','eFG','HiJ','IJK'],
+      f as ['abc','bcd','cde','def','efg','fgh','ghi','hij','ijk','jkl'],
+      results as [test."similarity-jaccard-sorted-check"(a,b,0.000000f),test."similarity-jaccard-sorted-check"(b,a,0.000000f),test."similarity-jaccard-sorted-check"(a,b,0.100000f),test."similarity-jaccard-sorted-check"(b,a,0.100000f),test."similarity-jaccard-sorted-check"(c,d,0.600000f),test."similarity-jaccard-sorted-check"(d,c,0.600000f),test."similarity-jaccard-sorted-check"(c,d,0.800000f),test."similarity-jaccard-sorted-check"(d,c,0.800000f),test."similarity-jaccard-sorted-check"(e,f,0.600000f),test."similarity-jaccard-sorted-check"(f,e,0.600000f),test."similarity-jaccard-sorted-check"(e,f,0.800000f),test."similarity-jaccard-sorted-check"(f,e,0.800000f)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.sqlpp
new file mode 100644
index 0000000..3e36180
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.query.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.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as [1,2,3,4,5],
+      c as [1,2,3,4,5,8,9],
+      d as [1,2,3,4,5,7,8,9,10,11],
+      results as [test."similarity-jaccard-sorted"(a,b),test."similarity-jaccard-sorted"(b,a),test."similarity-jaccard-sorted"(c,d),test."similarity-jaccard-sorted"(d,c)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.sqlpp
new file mode 100644
index 0000000..282bc14
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element paper
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Cooperative Transactions for Environments')
+where (test."similarity-jaccard-sorted"(paper_tokens,query_tokens) >= 0.5)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.sqlpp
new file mode 100644
index 0000000..dfc9711
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.query.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.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as ['abc','bcd','cde','def','efg'],
+      c as ['abc','bcd','cde','def','efg','hij','ijk'],
+      d as ['abc','bcd','cde','def','efg','fgh','ghi','hij','ijk','jkl'],
+      e as ['Abc','bCd','cdE','DEf','eFG','HiJ','IJK'],
+      f as ['abc','bcd','cde','def','efg','fgh','ghi','hij','ijk','jkl'],
+      results as [test."similarity-jaccard-sorted"(a,b),test."similarity-jaccard-sorted"(b,a),test."similarity-jaccard-sorted"(c,d),test."similarity-jaccard-sorted"(d,c),test."similarity-jaccard-sorted"(e,f),test."similarity-jaccard-sorted"(f,e)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.sqlpp
new file mode 100644
index 0000000..7b9fb5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.query.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.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as [1,2,3,4,5],
+      c as [1,2,3,4,5,8,9],
+      d as [1,2,3,4,5,7,8,9,10,11],
+      e as [4,3,5,8,9,2,1],
+      f as [7,5,8,9,3,10,1,2,11,4],
+      results as [test."similarity-jaccard"(a,b),test."similarity-jaccard"(b,a),test."similarity-jaccard"(c,d),test."similarity-jaccard"(d,c),test."similarity-jaccard"(e,f),test."similarity-jaccard"(f,e)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.1.ddl.sqlpp
new file mode 100644
index 0000000..83def9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int64,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table DBLP(DBLPType) primary key id on group1;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.2.update.sqlpp
new file mode 100644
index 0000000..2171531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.2.update.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;
+
+
+load  table DBLP using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.sqlpp
new file mode 100644
index 0000000..a6151a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+select element paper
+from  DBLP as paper
+with  paper_tokens as test."word-tokens"(paper.title),
+      query_tokens as test."word-tokens"('Transactions for Cooperative Environments')
+where (test."similarity-jaccard"(paper_tokens,query_tokens) >= 0.500000f)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.sqlpp
new file mode 100644
index 0000000..5d3740c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+with  a as [],
+      b as ['abc','bcd','cde','def','efg'],
+      c as ['abc','bcd','cde','def','efg','hij','ijk'],
+      d as ['abc','bcd','cde','def','efg','fgh','ghi','hij','ijk','jkl'],
+      e as ['efg','abc','cde','def','hij','ijk','bcd'],
+      f as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      g as ['Efg','aBc','cdE','DEf','hIJ','IjK','BCD'],
+      h as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      results as [test."similarity-jaccard"(a,b),test."similarity-jaccard"(b,a),test."similarity-jaccard"(c,d),test."similarity-jaccard"(d,c),test."similarity-jaccard"(e,f),test."similarity-jaccard"(f,e),test."similarity-jaccard"(g,h),test."similarity-jaccard"(h,g)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.ddl.sqlpp
new file mode 100644
index 0000000..fadcc09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.ddl.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Tweet as
+ closed {
+  id : int64,
+  tweetid : int64,
+  loc : point,
+  time : datetime,
+  text : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table TwitterData(Tweet) primary key id on group1;
+
+create  index rtree_index_point  on TwitterData (loc) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.2.update.sqlpp
new file mode 100644
index 0000000..d12f67e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.2.update.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;
+
+
+load  table TwitterData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.query.sqlpp
new file mode 100644
index 0000000..5047af8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+select element {'cell':c,'count':num}
+from  TwitterData as t
+with  keywords as 'Allergies',
+      region as test.polygon('\n\t33.80503407287759,-126.41235263538363 \n\t44.9090773200516,-126.41235263538363 \n\t44.9090773200516,-87.65258701038363 \n\t33.80503407287759,-87.65258701038363')
+where (test."spatial-intersect"(t.loc,region) and (t.time > test.datetime('2011-05-15T00:00:00Z')) and (t.time < test.datetime('2011-05-16T23:59:59Z')) and test.contains(t.text,keywords))
+group by test."spatial-cell"(t.loc,test."create-point"(24.5,-125.5),3.0,3.0) as c
+with  num as test.count(t)
+order by num
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.1.ddl.sqlpp
new file mode 100644
index 0000000..303a78f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  loc : point
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialDataAggregation.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.3.query.sqlpp
new file mode 100644
index 0000000..676457c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/cell-aggregation/cell-aggregation.3.query.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.
+ */
+
+use test;
+
+
+with  grid as (
+      select element {'cell':c,'count':num}
+      from  MyData as o
+      group by test."spatial-cell"(o.loc,test."create-point"(0.0,0.0),5.0,5.0) as c
+      with  num as test.count(o)
+      order by num
+  )
+select element g
+from  grid as g
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.3.query.sqlpp
new file mode 100644
index 0000000..90ae09c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(test."create-circle"(test."create-point"(0.0,0.0),5.0),o.circle)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.1.ddl.sqlpp
new file mode 100644
index 0000000..24b164d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.2.update.sqlpp
new file mode 100644
index 0000000..c1eb456
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.2.update.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.3.query.sqlpp
new file mode 100644
index 0000000..52e5238
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/circle_accessor/circle_accessor.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+use test;
+
+
+{'circle-radius':test."get-radius"(test."create-circle"(test."create-point"(6.0,3.0),1.0)),'circle-center':test."get-center"(test."create-circle"(test."create-point"(6.0,3.0),1.0))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.1.ddl.sqlpp
new file mode 100644
index 0000000..a2562b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.1.ddl.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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    : Create r-tree indexes for all spatial data types.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.SpatialType as
+{
+  id : int64,
+  point : point,
+  line1 : line,
+  poly1 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create  table MyData(SpatialType) primary key id;
+
+create  index rtree_index1  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.2.update.sqlpp
new file mode 100644
index 0000000..71623aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.2.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Create r-tree indexes for all spatial data types.
+ * Success        : Yes
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.3.query.sqlpp
new file mode 100644
index 0000000..640bec4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/create-rtree-index/create-rtree-index.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Create r-tree indexes for all spatial data types.
+ * Success        : Yes
+ */
+
+use test;
+
+
+select element a.id
+from  MyData as a
+order by a.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.3.query.sqlpp
new file mode 100644
index 0000000..bd6693e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/distance-between-points/distance-between-points.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id,'distance':distance}
+from  MyData as o
+with  distance as test."spatial-distance"(o.point,test."create-point"(0.0,0.0))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.3.query.sqlpp
new file mode 100644
index 0000000..7ed9da6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-circle/line-intersect-circle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.line1,test."create-circle"(test."create-point"(0.0,0.0),5.0))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.3.query.sqlpp
new file mode 100644
index 0000000..65aea96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-line/line-intersect-line.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.line1,o.line2)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.3.query.sqlpp
new file mode 100644
index 0000000..2a05a13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.line1,o.poly1)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.3.query.sqlpp
new file mode 100644
index 0000000..c07d407
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.line1,o.rec)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.1.ddl.sqlpp
new file mode 100644
index 0000000..24b164d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.2.update.sqlpp
new file mode 100644
index 0000000..c1eb456
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.2.update.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.3.query.sqlpp
new file mode 100644
index 0000000..a064436
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/line_accessor/line_accessor.3.query.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+use test;
+
+
+with  line as test."create-line"(test."create-point"(100.6,999.4),test."create-point"(-872.0,-876.9)),
+      line_list as test."get-points"(line)
+select element p
+from  line_list as p
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.3.query.sqlpp
new file mode 100644
index 0000000..20e7396
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-equals-point/point-equals-point.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-point"(5.0,1.0))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.3.query.sqlpp
new file mode 100644
index 0000000..6ba14bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-circle/point-in-circle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-circle"(test."create-point"(0.0,0.0),5.0))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.3.query.sqlpp
new file mode 100644
index 0000000..67a1ca9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-polygon/point-in-polygon.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,o.poly1)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.3.query.sqlpp
new file mode 100644
index 0000000..3585059
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-in-rectangle/point-in-rectangle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,o.rec)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.3.query.sqlpp
new file mode 100644
index 0000000..cf5a951
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point-on-line/point-on-line.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,o.line1)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.1.ddl.sqlpp
new file mode 100644
index 0000000..24b164d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.2.update.sqlpp
new file mode 100644
index 0000000..c1eb456
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.2.update.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.3.query.sqlpp
new file mode 100644
index 0000000..0cf25e27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/point_accessor/point_accessor.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+use test;
+
+
+{'x-coordinate':test."get-x"(test."create-point"(2.3,5.0)),'y-coordinate':test."get-y"(test."create-point"(2.3,5.0))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.3.query.sqlpp
new file mode 100644
index 0000000..c157f76
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.poly1,test."create-circle"(test."create-point"(6.0,3.0),1.0))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.3.query.sqlpp
new file mode 100644
index 0000000..b1eb903
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.poly1,o.poly2)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.3.query.sqlpp
new file mode 100644
index 0000000..5c7c79f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.poly1,o.rec)
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.1.ddl.sqlpp
new file mode 100644
index 0000000..24b164d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.2.update.sqlpp
new file mode 100644
index 0000000..c1eb456
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.2.update.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.3.query.sqlpp
new file mode 100644
index 0000000..9354503
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/polygon_accessor/polygon_accessor.3.query.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+use test;
+
+
+with  polygon as test."create-polygon"([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]),
+      polygon_list as test."get-points"(polygon)
+select element p
+from  polygon_list as p
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.3.query.sqlpp
new file mode 100644
index 0000000..d9641d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.rec,test."create-circle"(test."create-point"(4.1,4.1),1.0))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.1.ddl.sqlpp
new file mode 100644
index 0000000..4637d6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int64,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.query.sqlpp
new file mode 100644
index 0000000..a63f2e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.rec,test."create-rectangle"(test."create-point"(4.5,9.0),test."create-point"(-1.0,5.0)))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.1.ddl.sqlpp
new file mode 100644
index 0000000..24b164d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.2.update.sqlpp
new file mode 100644
index 0000000..c1eb456
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.2.update.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.3.query.sqlpp
new file mode 100644
index 0000000..3ec08f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/rectangle_accessor/rectangle_accessor.3.query.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.
+ */
+/*
+ * Description      :   Test spatial accessors
+ * Expected Result  :   Success
+ * Date             :   Oct 17, 2012
+ */
+
+use test;
+
+
+with  rectangle as test."create-rectangle"(test."create-point"(9.2,49.0),test."create-point"(77.8,111.1)),
+      rectangle_list as test."get-points"(rectangle)
+select element p
+from  rectangle_list as p
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.1.ddl.sqlpp
new file mode 100644
index 0000000..7ef1976
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+{
+  id : int32,
+  point : point,
+  kwds : string
+}
+
+create external  table MyData(MyRecord) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.3.query.sqlpp
new file mode 100644
index 0000000..221f5e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/spatial/spatial-area/spatial-area.3.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;
+
+
+{'polygonArea':test."spatial-area"(test."create-polygon"([1.0,1.0,1.0,4.0,3.0,4.0,3.0,1.0])),'circleArea':test."spatial-area"(test."create-circle"(test."create-point"(0.0,0.0),1.0)),'rectangleArea':test."spatial-area"(test."create-rectangle"(test."create-point"(0.0,5.0),test."create-point"(8.0,8.0)))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.3.query.sqlpp
new file mode 100644
index 0000000..cfcc0b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string1/codepoint-to-string1.3.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;
+
+
+{'result1':test."codepoint-to-string"([20013,25991,23383,31526])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.3.query.sqlpp
new file mode 100644
index 0000000..9cb6075
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/codepoint-to-string2/codepoint-to-string2.3.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;
+
+
+{'f1':test."codepoint-to-string"([]),'f2':test."codepoint-to-string"([97,98,99])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.3.query.sqlpp
new file mode 100644
index 0000000..7ce3f6e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_01/concat_01.3.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;
+
+
+{'result1':test."string-concat"(['aa','25991','bb','31526']),'result2':test."string-concat"([])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.1.ddl.sqlpp
new file mode 100644
index 0000000..7c4eb4d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.1.ddl.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.
+ */
+/*
+ * Description    : Test concat-string function with nulls in the list which is passed as an argument.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.2.update.sqlpp
new file mode 100644
index 0000000..0de70ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.2.update.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.
+ */
+/*
+ * Description    : Test concat-string function with nulls in the list which is passed as an argument.
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.3.query.sqlpp
new file mode 100644
index 0000000..9fd5590
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_02/concat_02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Test concat-string function with nulls in the list which is passed as an argument.
+ * Success        : Yes
+ */
+
+use test;
+
+
+{'a':test."string-concat"([null]),'b':test."string-concat"([null,'foo']),'c':test."string-concat"(['foo',null])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.1.ddl.sqlpp
new file mode 100644
index 0000000..703b79e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.1.ddl.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.
+ */
+/*
+ * Description    : Test concat-string function with heterogenous elements in a list
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.2.update.sqlpp
new file mode 100644
index 0000000..71957e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.2.update.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.
+ */
+/*
+ * Description    : Test concat-string function with heterogenous elements in a list
+ * Success        : Yes
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.3.query.sqlpp
new file mode 100644
index 0000000..4fb9051
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/concat_03/concat_03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Test concat-string function with nulls in the list which is passed as an argument.
+ * Success        : Yes
+ */
+
+use test;
+
+
+with  k as [{'a':1,'b':'hello'},{'a':2,'b':{'k':[1,2,2]}}]
+select element test."string-concat"([x.b,' world'])
+from  k as x
+where (x.a = 1)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.3.query.sqlpp
new file mode 100644
index 0000000..c1f2bf0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/constructor/constructor.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+with  a as 1,
+      b as 2,
+      c as 'c',
+      d as [a,b,c]
+select element test.string(x)
+from  d as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.3.query.sqlpp
new file mode 100644
index 0000000..f616737
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/contains_01/contains_01.3.query.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.
+ */
+
+use test;
+
+
+select element [test.contains(x,'ofo'),test.contains(y,'ofo')]
+from  ['foofoo'] as x,
+      ['barbar'] as y
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.1.ddl.sqlpp
new file mode 100644
index 0000000..36b2503
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : cpttostr01.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Pass the codepoints which are in the internal dataset to the function. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  cpt : [int32]
+}
+
+create  table testds(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.2.update.sqlpp
new file mode 100644
index 0000000..6f84b11
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name : cpttostr01.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Pass the codepoints which are in the internal dataset to the function. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':123,'cpt':[48,45,57,44,65,45,90]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.3.query.sqlpp
new file mode 100644
index 0000000..41d8e71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr01/cpttostr01.3.query.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.
+ */
+/*
+ * Test case Name : cpttostr01.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Pass the codepoints which are in the internal dataset to the function. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+use test;
+
+
+select element test."codepoint-to-string"(l.cpt)
+from  testds as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.1.ddl.sqlpp
new file mode 100644
index 0000000..04bd867
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.1.ddl.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.
+ */
+/*
+ * Test case Name : cpttostr02.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Inputs are codepoint values for lowecase, uppercase and special characters
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.2.update.sqlpp
new file mode 100644
index 0000000..04bd867
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.2.update.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.
+ */
+/*
+ * Test case Name : cpttostr02.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Inputs are codepoint values for lowecase, uppercase and special characters
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.3.query.sqlpp
new file mode 100644
index 0000000..0b69474
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr02/cpttostr02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : cpttostr02.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Inputs are codepoint values for lowecase, uppercase and special characters
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+{'c1':"codepoint-to-string"([65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]),'c2':"codepoint-to-string"([97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122]),'c3':"codepoint-to-string"([33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,63,64])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.1.ddl.sqlpp
new file mode 100644
index 0000000..4d87ef3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.1.ddl.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.
+ */
+/*
+ * Test case Name : cpttostr04.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.2.update.sqlpp
new file mode 100644
index 0000000..4d87ef3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.2.update.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.
+ */
+/*
+ * Test case Name : cpttostr04.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.3.query.sqlpp
new file mode 100644
index 0000000..eea31c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/cpttostr04/cpttostr04.3.query.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.
+ */
+/*
+ * Test case Name : cpttostr04.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+{'c1':"codepoint-to-string"("string-to-codepoint"('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.3.query.sqlpp
new file mode 100644
index 0000000..019e3ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with1/end-with1.3.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;
+
+
+{'result1':test."end-with"('hello world','werld')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.3.query.sqlpp
new file mode 100644
index 0000000..edc45ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with2/end-with2.3.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;
+
+
+{'result1':test."end-with"('hello world',' world')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.3.query.sqlpp
new file mode 100644
index 0000000..a9b5573
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with3/end-with3.3.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;
+
+
+{'result1':test."end-with"('ends','')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.3.query.sqlpp
new file mode 100644
index 0000000..3d84a3a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with4/end-with4.3.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;
+
+
+{'result1':test."end-with"('ends','ss')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.3.query.sqlpp
new file mode 100644
index 0000000..2f1012e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/end-with5/end-with5.3.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;
+
+
+{'f1':test."end-with"('ends','s'),'f2':test."end-with"('start',null),'f3':test."end-with"(null,null),'f4':test."end-with"('',null),'f5':test."end-with"('',''),'f6':test."end-with"(null,'')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.3.query.sqlpp
new file mode 100644
index 0000000..39957db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/ends-with_01/ends-with_01.3.query.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.
+ */
+
+use test;
+
+
+select element [test."ends-with"(x,'ar'),test."ends-with"(y,'ar')]
+from  ['foofoo'] as x,
+      ['barbar'] as y
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.1.ddl.sqlpp
new file mode 100644
index 0000000..a8f38a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.1.ddl.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.
+ */
+/*
+ * Testcase Name : endwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.2.update.sqlpp
new file mode 100644
index 0000000..a8f38a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.2.update.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.
+ */
+/*
+ * Testcase Name : endwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.3.query.sqlpp
new file mode 100644
index 0000000..d1881cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith02/endwith02.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name : endwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+select element a
+from  ["end-with"('aBCDEFghIa',"codepoint-to-string"([41])),"end-with"('AbCDEFghIA',"codepoint-to-string"([41])),"end-with"('AbCdEfGhIjKlMnOpQrStUvWxYz','xYz'),"end-with"('abcdef',lowercase('ABCDEf')),"end-with"('abcdef','abcdef'),"end-with"('abcdef123','ef123')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.1.ddl.sqlpp
new file mode 100644
index 0000000..95bc902
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : endwith03.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table testds(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.2.update.sqlpp
new file mode 100644
index 0000000..0c6d30a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : endwith03.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'name':'Jim Jones'};
+insert into testds
+select element {'name':'Ravi Kumar'};
+insert into testds
+select element {'name':'Bruce Li'};
+insert into testds
+select element {'name':'Marian Jones'};
+insert into testds
+select element {'name':'Phil Jones'};
+insert into testds
+select element {'name':'I am Jones'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.3.query.sqlpp
new file mode 100644
index 0000000..f691356
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/endwith03/endwith03.3.query.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.
+ */
+/*
+ * Testcase Name : endwith03.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+where test."end-with"(l.name,'Jones')
+order by l.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/escapes01/escapes01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/escapes01/escapes01.3.query.sqlpp
new file mode 100644
index 0000000..f6e430d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/escapes01/escapes01.3.query.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.
+ */
+
+select element "string-concat"(['1\f2\n3\t4\r56\b7"8','\'9']);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/escapes02/escapes02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/escapes02/escapes02.3.query.sqlpp
new file mode 100644
index 0000000..aaccc9c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/escapes02/escapes02.3.query.sqlpp
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.3.query.sqlpp
new file mode 100644
index 0000000..24e14a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_01/length_01.3.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;
+
+
+{'result1':test."string-length"('hellow'),'result2':test."string-length"(''),'result3':test."string-length"(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.3.query.sqlpp
new file mode 100644
index 0000000..16973d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/length_02/length_02.3.query.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 element test."string-length"(x)
+from  ['ten','twenty','thirty','forty','fifty','sixty','seventy','ninety'] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.3.query.sqlpp
new file mode 100644
index 0000000..c5ebc10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_01/like_01.3.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;
+
+
+select element [test.like('A6BBB','_6%'),test.like('A8BBB','_6%')];
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.3.query.sqlpp
new file mode 100644
index 0000000..caa1618
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/like_null/like_null.3.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;
+
+
+{'field1':test.like('A8BBB',null),'field2':test.like(null,'_6%')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.3.query.sqlpp
new file mode 100644
index 0000000..bd6c676
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/lowercase/lowercase.3.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;
+
+
+{'result1':test.lowercase('HEllow'),'result2':test.lowercase(''),'result3':test.lowercase(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.1.ddl.sqlpp
new file mode 100644
index 0000000..ac87d47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.1.ddl.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.
+ */
+/*
+ * Testcase Name  :  matches02.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.2.update.sqlpp
new file mode 100644
index 0000000..ac87d47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.2.update.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.
+ */
+/*
+ * Testcase Name  :  matches02.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.3.query.sqlpp
new file mode 100644
index 0000000..372405e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches02/matches02.3.query.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.
+ */
+/*
+ * Testcase Name  :  matches02.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
+{'c3':matches('Hello World','Hello World'),'c4':matches('Asterix for Dummies','Asterix for Dummies'),'c5':matches('semistructured data',lowercase('SEMISTRUCTURED DATA')),'c6':matches('Mega Living!','Mega'),'c7':matches('Mega Living!','ving!'),'c8':matches('Mega Living!',' '),'c9':matches('Mega Living!','a l'),'c10':matches('Mega Living!',''),'c11':matches(' ',' '),'c12':matches('aaaa','aaaaa')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.1.ddl.sqlpp
new file mode 100644
index 0000000..20be00d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.1.ddl.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.
+ */
+/*
+ * Testcase Name  :  matches03.aql
+ * Description    :  Positive tests
+ *                :  Test matches functions with regular expressions as third input parameter
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.2.update.sqlpp
new file mode 100644
index 0000000..20be00d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.2.update.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.
+ */
+/*
+ * Testcase Name  :  matches03.aql
+ * Description    :  Positive tests
+ *                :  Test matches functions with regular expressions as third input parameter
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.3.query.sqlpp
new file mode 100644
index 0000000..ede5f1d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches03/matches03.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name  :  matches03.aql
+ * Description    :  Positive tests
+ *                :  Test matches functions with regular expressions as third input parameter
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
+select element a
+from  [matches('1234567890','[^a-z]'),matches('1234567890','[^a-zA-Z]'),matches('abcdefghABCDEFGH','[^a-zA-Z]'),matches('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[^a-zA-Z]'),matches('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[^A-Z]'),matches('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[^a-z]'),matches('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[^0-9]'),matches('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[0-9]'),matches('adefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[a-z&&[^bc]]'),matches('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','[a-z&&[^bc]]'),matches('bc','[a-z&&[^bc]]'),matches('mnop','[a-z&&[^m-p]]'),matches('abcdmnop','[a-z&&[^m-p]]')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.1.ddl.sqlpp
new file mode 100644
index 0000000..cc26804
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.1.ddl.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.
+ */
+/*
+ * Testcase Name  :  matches04.aql
+ * Description    :  Positive tests
+ * Success        :  Yes (tests to check for patterns using regular expressions)
+ * Date           :  20th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.2.update.sqlpp
new file mode 100644
index 0000000..cc26804
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.2.update.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.
+ */
+/*
+ * Testcase Name  :  matches04.aql
+ * Description    :  Positive tests
+ * Success        :  Yes (tests to check for patterns using regular expressions)
+ * Date           :  20th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.3.query.sqlpp
new file mode 100644
index 0000000..ef55776
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches04/matches04.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name  :  matches04.aql
+ * Description    :  Positive tests
+ * Success        :  Yes (tests to check for patterns using regular expressions)
+ * Date           :  20th April 2012
+ */
+
+select element a
+from  [matches('UCI UCI UCI UCI UCI UCI','[UCI{6}]'),matches('UCI UCI UCI UCI UCI UCI','[UCI{3,6}]'),matches('UCI UCI UCI UCI UCI UCI','[UCI{7}]'),matches('UCI UCI UCI UCI UCI UCI','[UCI{1}]'),matches('UCI UCI UCI','[UCI+]'),matches('false','[true|false]'),matches('YX','[XY]')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.1.ddl.sqlpp
new file mode 100644
index 0000000..b61b257
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  :  matches05.aql
+ * Description    :  Positive tests
+ *                :  Create two internal datasets and insert string data and perform match of fname using matches function.
+ * Success        :  Yes
+ * Date           :  25th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType1 as
+{
+  fname : string,
+  lname : string,
+  id : int64
+}
+
+create  table testds1(TestType1) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.2.update.sqlpp
new file mode 100644
index 0000000..744be4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.2.update.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.
+ */
+/*
+ * Testcase Name  :  matches05.aql
+ * Description    :  Positive tests
+ *                :  Create two internal datasets and insert string data and perform match of fname using matches function.
+ * Success        :  Yes
+ * Date           :  25th April 2012
+ */
+
+use test;
+
+
+insert into testds1
+select element {'fname':'Test','lname':'Test','id':123};
+insert into testds1
+select element {'fname':'Testa','lname':'Test','id':124};
+insert into testds1
+select element {'fname':'Test1','lname':'Test1','id':125};
+insert into testds1
+select element {'fname':'Test','lname':'Testb','id':126};
+insert into testds1
+select element {'fname':'Test2','lname':'Test2','id':127};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.3.query.sqlpp
new file mode 100644
index 0000000..a9a37c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches05/matches05.3.query.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.
+ */
+/*
+ * Testcase Name  :  matches05.aql
+ * Description    :  Positive tests
+ *                :  Create two internal datasets and insert string data and perform match of fname using matches function.
+ * Success        :  Yes
+ * Date           :  25th April 2012
+ */
+
+use test;
+
+
+select element l
+from  testds1 as l
+where test.matches(l.fname,l.lname)
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.1.ddl.sqlpp
new file mode 100644
index 0000000..8fe21b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.1.ddl.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.
+ */
+/*
+ * Description  : Test matches string function using regular expressions
+ * Expected Res : Success
+ * Date         : May 21 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.2.update.sqlpp
new file mode 100644
index 0000000..8fe21b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.2.update.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.
+ */
+/*
+ * Description  : Test matches string function using regular expressions
+ * Expected Res : Success
+ * Date         : May 21 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.3.query.sqlpp
new file mode 100644
index 0000000..b7a6efc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches06/matches06.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Test matches string function using regular expressions
+ * Expected Res : Success
+ * Date         : May 21 2012
+ */
+
+select element a
+from  [matches('mnop','.'),matches('abcdefABCDEF','/d'),matches('12345','\\d'),matches('abcdefGHIJK','\\D'),matches('       ','\\s'),matches('       ','\\S'),matches('Welcome to pattern matching!','[a-zA-Z_0-9]'),matches('!@#$%^&*()','[a-zA-Z_0-9]'),matches('!@#$%^&*()','[^\\W]'),matches('!@#$%^&*','[^\\w]'),matches('0xffff','[\\p{XDigit}]'),matches('FFFFFFFF','[\\p{XDigit}]'),matches('abcdefgh','[\\p{javaLowerCase}]'),matches('ABCDEF','[\\p{javaLowerCase}]'),matches("codepoint-to-string"([163]),'[\\p{Sc}]')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.3.query.sqlpp
new file mode 100644
index 0000000..ef57ddf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches1/matches1.3.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;
+
+
+{'result1':test.matches('abracadabra','bra')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.1.ddl.sqlpp
new file mode 100644
index 0000000..23fe14d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.1.ddl.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.
+ */
+/*
+ * Testcase Name  :  matches11.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  20th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.2.update.sqlpp
new file mode 100644
index 0000000..23fe14d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.2.update.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.
+ */
+/*
+ * Testcase Name  :  matches11.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  20th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.3.query.sqlpp
new file mode 100644
index 0000000..35099a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches11/matches11.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name  :  matches11.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  20th April 2012
+ */
+
+select element a
+from  [matches('hello',null),matches('hello','helllo'),matches('hello',' '),matches(null,'hello'),matches('hello','[^a-z]')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.3.query.sqlpp
new file mode 100644
index 0000000..db722ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches2/matches2.3.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;
+
+
+{'result1':test.matches('abracadabra','^a.*a$')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.3.query.sqlpp
new file mode 100644
index 0000000..a31dbc3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches21/matches21.3.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;
+
+
+{'result1':test.matches('abracadabra','Bra','')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.3.query.sqlpp
new file mode 100644
index 0000000..908b6c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches22/matches22.3.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;
+
+
+{'result1':test.matches('abracadabra','Bra','i')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.3.query.sqlpp
new file mode 100644
index 0000000..550a840
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches23/matches23.3.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;
+
+
+{'result1':test.matches('helloworld','hello world','x')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.3.query.sqlpp
new file mode 100644
index 0000000..a64de72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matches3/matches3.3.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;
+
+
+{'result1':test.matches('abracadabra','^bra')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.3.query.sqlpp
new file mode 100644
index 0000000..6f61149
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/matchesnull/matchesnull.3.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;
+
+
+{'result1':test.matches('helloworld',null),'result2':test.matches('',null),'result3':test.matches(null,null),'result4':test.matches('helloworld',null,''),'result5':test.matches('',null,'i'),'result6':test.matches(null,null,null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.query.sqlpp
new file mode 100644
index 0000000..93cb554
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.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;
+
+
+{'result1':test.replace('abracadabra','a',''),'result2':test.replace('abracadabra','a(.)','a$1$1'),'result3':test.replace('darted','^(.*?)d(.*)$','$1c$2')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.query.sqlpp
new file mode 100644
index 0000000..e8d5e6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.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;
+
+
+{'result1':test.replace('abracadabra','bra','*')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.query.sqlpp
new file mode 100644
index 0000000..25e5559
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.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;
+
+
+{'result1':test.replace('abracadabra','Bra','kkk',''),'result2':test.replace('abracadabra','Bra','kkk','i'),'result3':test.replace('helloworld','hello world','kkk','x')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.query.sqlpp
new file mode 100644
index 0000000..4772d91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.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;
+
+
+{'result1':test.replace('abracadabra','',null,null),'result2':test.replace('abracadabra','bra','XXX',''),'result3':test.replace(null,'hello world','XxXx','x'),'result4':test.replace('abracadabra','bra','XXX',null),'result5':test.replace('abracadabra',null,'XXX',null),'result6':test.replace('abracadabra','Bra',null,'i'),'result7':test.replace('abracadabra','Bra','','i'),'result8':test.replace('abracadabra','','XXX','')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.query.sqlpp
new file mode 100644
index 0000000..a0eb4b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.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;
+
+
+{'result1':test.replace('abracadabra','a.*a','*')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.3.query.sqlpp
new file mode 100644
index 0000000..8f14b3a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with1/start-with1.3.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;
+
+
+{'result1':test."start-with"('start','st')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.3.query.sqlpp
new file mode 100644
index 0000000..61473d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with2/start-with2.3.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;
+
+
+{'result1':test."start-with"('start','t')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.3.query.sqlpp
new file mode 100644
index 0000000..2adc661
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with3/start-with3.3.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;
+
+
+{'result1':test."start-with"('start','start')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.3.query.sqlpp
new file mode 100644
index 0000000..0b1abea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with4/start-with4.3.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;
+
+
+{'f1':test."start-with"('start',''),'f2':test."start-with"('start',null),'f3':test."start-with"(null,null),'f4':test."start-with"('',null),'f5':test."start-with"('',''),'f6':test."start-with"(null,'')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.3.query.sqlpp
new file mode 100644
index 0000000..dc2b654
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/start-with5/start-with5.3.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;
+
+
+{'result1':test."start-with"('','s')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.3.query.sqlpp
new file mode 100644
index 0000000..b52490a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/starts-with_01/starts-with_01.3.query.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.
+ */
+
+use test;
+
+
+select element [test."starts-with"(x,'ba'),test."starts-with"(y,'ba')]
+from  ['foofoo'] as x,
+      ['barbar'] as y
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.1.ddl.sqlpp
new file mode 100644
index 0000000..f088376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.1.ddl.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.
+ */
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.2.update.sqlpp
new file mode 100644
index 0000000..f088376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.2.update.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.
+ */
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.3.query.sqlpp
new file mode 100644
index 0000000..60b1d60
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith02/startwith02.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+select element a
+from  ["start-with"('Hello','H'),"start-with"('Hello',lowercase('He')),"start-with"('Hello',''),"start-with"('Hello',' '),"start-with"('Hello',null),"start-with"('abcdef',lowercase('ABCDEf')),"start-with"('abcdef','abcdef'),"start-with"('abcdef','abc '),"start-with"('abc\\tdef','abc\\t'),"start-with"(' abcdef','abc'),"start-with"('0x1FF','0'),"start-with"('<ID>','<'),"start-with"('aBCDEFghI',"codepoint-to-string"([41])),"start-with"('AbCDEFghI',"codepoint-to-string"([41]))] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.1.ddl.sqlpp
new file mode 100644
index 0000000..188488b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table testds(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.2.update.sqlpp
new file mode 100644
index 0000000..580d46f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'name':'John Smith'};
+insert into testds
+select element {'name':'John Doe'};
+insert into testds
+select element {'name':'John Wayne'};
+insert into testds
+select element {'name':'Johnson Ben'};
+insert into testds
+select element {'name':'Johnny Walker'};
+insert into testds
+select element {'name':'David Smith'};
+insert into testds
+select element {'name':'Not a Name'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.3.query.sqlpp
new file mode 100644
index 0000000..3e74a08
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/startwith03/startwith03.3.query.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.
+ */
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+use test;
+
+
+select element l
+from  testds as l
+where test."start-with"(l.name,'John')
+order by l.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.1.ddl.sqlpp
new file mode 100644
index 0000000..6426040
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+/*
+ * Test case Name : strconcat01.aql
+ * Description    : Test string-concat([string]) function.
+ *                : Pass the strings(which are in internal dataset) to string-concat function for concatenation. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : int32,
+  fname : string,
+  lname : string
+}
+
+create  table testds(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.2.update.sqlpp
new file mode 100644
index 0000000..dca3990
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.2.update.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.
+ */
+/*
+ * Test case Name : strconcat01.aql
+ * Description    : Test string-concat([string]) function.
+ *                : Pass the strings(which are in internal dataset) to string-concat function for concatenation. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'id':123,'fname':'John','lname':'Smith'};
+insert into testds
+select element {'id':124,'fname':'Bob','lname':'Jones'};
+insert into testds
+select element {'id':125,'fname':'Mike','lname':'Carey'};
+insert into testds
+select element {'id':126,'fname':'Chen','lname':'Li'};
+insert into testds
+select element {'id':121,'fname':'Young Seok','lname':'Kim'};
+insert into testds
+select element {'id':122,'fname':'Alex','lname':'Behm'};
+insert into testds
+select element {'id':127,'fname':'Raman','lname':'Grover'};
+insert into testds
+select element {'id':128,'fname':'Yingyi','lname':'Bu'};
+insert into testds
+select element {'id':129,'fname':'Vinayak','lname':'Borkar'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.3.query.sqlpp
new file mode 100644
index 0000000..66577ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat01/strconcat01.3.query.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.
+ */
+/*
+ * Test case Name : strconcat01.aql
+ * Description    : Test string-concat([string]) function.
+ *                : Pass the strings(which are in internal dataset) to string-concat function for concatenation. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+use test;
+
+
+select element {'Full Name':test."string-concat"([l.fname,l.lname])}
+from  testds as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.1.ddl.sqlpp
new file mode 100644
index 0000000..72e3e07
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.1.ddl.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.
+ */
+/*
+ * Description    : Test string-concat([string]) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.2.update.sqlpp
new file mode 100644
index 0000000..72e3e07
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.2.update.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.
+ */
+/*
+ * Description    : Test string-concat([string]) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.3.query.sqlpp
new file mode 100644
index 0000000..f5d7e20
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strconcat02/strconcat02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Test string-concat([string]) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+select element a
+from  ["string-concat"(["codepoint-to-string"("string-to-codepoint"('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')),"codepoint-to-string"("string-to-codepoint"('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')),"codepoint-to-string"("string-to-codepoint"('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'))]),"string-concat"([' ','a','b','  ','c','d','e','f','g','p','o','q','r','s','t',' ']),"string-concat"(['This is a test','and all tests must pass','and life is good...'])] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.3.query.sqlpp
new file mode 100644
index 0000000..f936b7c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-concat1/string-concat1.3.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;
+
+
+{'result1':test."string-concat"(['aa','25991','bb','31526'])};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.3.query.sqlpp
new file mode 100644
index 0000000..c5febdb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal1/string-equal1.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'result1':test."string-equal"('test','tess')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.3.query.sqlpp
new file mode 100644
index 0000000..94ba3d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal2/string-equal2.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'result1':test."string-equal"('test','test')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.3.query.sqlpp
new file mode 100644
index 0000000..1db5874
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal3/string-equal3.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'result1':test."string-equal"('test11','test')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.3.query.sqlpp
new file mode 100644
index 0000000..a51db37
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-equal4/string-equal4.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'result1':test."string-equal"('',''),'result3':test."string-equal"(null,''),'result4':test."string-equal"('',null),'result5':test."string-equal"(null,null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.3.query.sqlpp
new file mode 100644
index 0000000..ee1946a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-join1/string-join1.3.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;
+
+
+{'result0':test."string-join"(['aa','25991','bb','31526'],'::'),'result1':test."string-join"(['aa','25991','bb','31526'],'')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.3.query.sqlpp
new file mode 100644
index 0000000..6b884f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint/string-to-codepoint.3.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;
+
+
+{'result1':test."string-to-codepoint"('abcd')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.3.query.sqlpp
new file mode 100644
index 0000000..cd89f63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint1/string-to-codepoint1.3.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;
+
+
+{'result1':test."string-to-codepoint"('')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.3.query.sqlpp
new file mode 100644
index 0000000..d5ffb23
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/string-to-codepoint2/string-to-codepoint2.3.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;
+
+
+{'result1':test."string-to-codepoint"('欢迎')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.1.ddl.sqlpp
new file mode 100644
index 0000000..39dcbd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.1.ddl.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.
+ */
+/*
+ * Description    : Test string-length(string) function 
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.2.update.sqlpp
new file mode 100644
index 0000000..39dcbd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.2.update.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.
+ */
+/*
+ * Description    : Test string-length(string) function 
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.3.query.sqlpp
new file mode 100644
index 0000000..370740f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen02/strlen02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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    : Test string-length(string) function 
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+select element a
+from  ["string-length"('abcdefghijklmnopqrstu'),"string-length"('ABCDEFGHIJKLMNOPQRSTU'),"string-length"('abcdEFGHijklMNOPqrstu'),"string-length"('abcd EFGH ijkl MNOP qrstu'),"string-length"('   Hello World    !!!!....:-)'),"string-length"('~!@#$%^&*()_+{}:?<>/.,\';`][\\')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.1.ddl.sqlpp
new file mode 100644
index 0000000..a5136ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.1.ddl.sqlpp
@@ -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    : Test string-length(string) function 
+ * Expected Res   : Success
+ * Date           : 19th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table testds(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.2.update.sqlpp
new file mode 100644
index 0000000..7093b4b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.2.update.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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    : Test string-length(string) function 
+ * Expected Res   : Success
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'name':'Maradona'};
+insert into testds
+select element {'name':'Pele'};
+insert into testds
+select element {'name':'Roberto Baggio'};
+insert into testds
+select element {'name':'Beckham David'};
+insert into testds
+select element {'name':'Rooney'};
+insert into testds
+select element {'name':'Ronaldinho'};
+insert into testds
+select element {'name':'Ronaldo'};
+insert into testds
+select element {'name':'Zinadine Zidane'};
+insert into testds
+select element {'name':'Cristiano Ronaldo'};
+insert into testds
+select element {'name':'Messi'};
+insert into testds
+select element {'name':'Tevez'};
+insert into testds
+select element {'name':'Henry'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.3.query.sqlpp
new file mode 100644
index 0000000..532239e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strlen03/strlen03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Test string-length(string) function 
+ * Expected Res   : Success
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+select element test."string-length"(l.name)
+from  testds as l
+order by l.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.1.ddl.sqlpp
new file mode 100644
index 0000000..4427dc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.1.ddl.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.
+ */
+/*
+ * Description  : Test string to codepoint function with valid inputs
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.2.update.sqlpp
new file mode 100644
index 0000000..4427dc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.2.update.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.
+ */
+/*
+ * Description  : Test string to codepoint function with valid inputs
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.3.query.sqlpp
new file mode 100644
index 0000000..5205e23
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt01/strtocpt01.3.query.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.
+ */
+/*
+ * Description  : Test string to codepoint function with valid inputs
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+"string-to-codepoint"('ABCDEFGHIJKLMNOPQRSTUVWXYZ-01234567890');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.1.ddl.sqlpp
new file mode 100644
index 0000000..e488bbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.1.ddl.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.
+ */
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.2.update.sqlpp
new file mode 100644
index 0000000..e488bbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.2.update.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.
+ */
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.3.query.sqlpp
new file mode 100644
index 0000000..586c19e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt02/strtocpt02.3.query.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.
+ */
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+"string-to-codepoint"('"\'-=_+|\\,./<>?:;~`');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.1.ddl.sqlpp
new file mode 100644
index 0000000..e488bbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.1.ddl.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.
+ */
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.2.update.sqlpp
new file mode 100644
index 0000000..e488bbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.2.update.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.
+ */
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.3.query.sqlpp
new file mode 100644
index 0000000..d72077f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/strtocpt03/strtocpt03.3.query.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.
+ */
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+"string-to-codepoint"('!@#$%^&*()');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.1.ddl.sqlpp
new file mode 100644
index 0000000..76880bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.1.ddl.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.
+ */
+/*
+ * Testcase Name  : substr01.aql
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.2.update.sqlpp
new file mode 100644
index 0000000..76880bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.2.update.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.
+ */
+/*
+ * Testcase Name  : substr01.aql
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.3.query.sqlpp
new file mode 100644
index 0000000..e264362
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr01/substr01.3.query.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.
+ */
+/*
+ * Testcase Name  : substr01.aql
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
+{'str2':substring('Hello World',10),'str4':substring('This is a test string',21),'str6':substring('This is a test string',22),'str8':substring('This is a test string',0),'str10':substring('This is a test string',-1),'str13':substring("string-concat"(['This is a test string','This is a another test string']),21),'str14':substring('UC Irvine',("string-length"('UC Irvine') / 2))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.1.ddl.sqlpp
new file mode 100644
index 0000000..dcaa12f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.1.ddl.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.
+ */
+/*
+ * Testcase Name  : substr04.aql
+ * Description    : Test substring(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.2.update.sqlpp
new file mode 100644
index 0000000..dcaa12f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.2.update.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.
+ */
+/*
+ * Testcase Name  : substr04.aql
+ * Description    : Test substring(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.3.query.sqlpp
new file mode 100644
index 0000000..eedcdfa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr04/substr04.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name  : substr04.aql
+ * Description    : Test substring(string, position, length) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
+select element a
+from  [substring('hello world',7,5),substring('hello world',1,11),substring('hello world',3,9),substring('ABCD',3,2),substring('ABCD',1,4),substring('UC Irvine',4,("string-length"('UC Irvine') - 3)),substring('UC Irvine',1,"string-length"('UC Irvine')),substring(substring('UC Irvine',4),1,"string-length"('Irvine'))] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.1.ddl.sqlpp
new file mode 100644
index 0000000..c41d0ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : substr05.aql
+ * Description    : Test substring(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table testdst(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.2.update.sqlpp
new file mode 100644
index 0000000..d7dfc32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.2.update.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Testcase Name  : substr05.aql
+ * Description    : Test substring(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+insert into testdst
+select element {'name':'UC Berkeley'};
+insert into testdst
+select element {'name':'UC Irvine'};
+insert into testdst
+select element {'name':'UC LA'};
+insert into testdst
+select element {'name':'UC Riverside'};
+insert into testdst
+select element {'name':'UC San Diego'};
+insert into testdst
+select element {'name':'UC Santa Barbara'};
+insert into testdst
+select element {'name':'UT Austin '};
+insert into testdst
+select element {'name':'UT Dallas'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.3.query.sqlpp
new file mode 100644
index 0000000..83407eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr05/substr05.3.query.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.
+ */
+/*
+ * Testcase Name  : substr05.aql
+ * Description    : Test substring(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+select element test.substring(a.name,4,(test."string-length"(a.name) - 3))
+from  testdst as a
+order by a.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.1.ddl.sqlpp
new file mode 100644
index 0000000..39cb881
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.1.ddl.sqlpp
@@ -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    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table testdst(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.2.update.sqlpp
new file mode 100644
index 0000000..45b976e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.2.update.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+insert into testdst
+select element {'name':'UC Berkeley'};
+insert into testdst
+select element {'name':'UC Irvine'};
+insert into testdst
+select element {'name':'UC LA'};
+insert into testdst
+select element {'name':'UC Riverside'};
+insert into testdst
+select element {'name':'UC San Diego'};
+insert into testdst
+select element {'name':'UC Santa Barbara'};
+insert into testdst
+select element {'name':'UT Austin '};
+insert into testdst
+select element {'name':'UT Dallas'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.3.query.sqlpp
new file mode 100644
index 0000000..991a911
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substr06/substr06.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+select element test.substring(a.name,4)
+from  testdst as a
+order by a.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.3.query.sqlpp
new file mode 100644
index 0000000..7a2ad81
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-1/substring-after-1.3.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;
+
+
+{'result1':test."substring-after"('HEllow','El')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.3.query.sqlpp
new file mode 100644
index 0000000..23211ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-2/substring-after-2.3.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;
+
+
+{'result1':test."substring-after"('HEllow','1')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.3.query.sqlpp
new file mode 100644
index 0000000..6f89a7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-3/substring-after-3.3.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;
+
+
+{'result1':test."substring-after"('HEllow','HEllow')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.3.query.sqlpp
new file mode 100644
index 0000000..0497f0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-after-4/substring-after-4.3.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;
+
+
+{'result1':test."substring-after"('HEllow',''),'result2':test."substring-after"('HEllow',null),'result3':test."substring-after"('',null),'result4':test."substring-after"('',''),'result5':test."substring-after"(null,null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.3.query.sqlpp
new file mode 100644
index 0000000..1041144
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-1/substring-before-1.3.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;
+
+
+{'result1':test."substring-before"('HEllow','ll')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.3.query.sqlpp
new file mode 100644
index 0000000..f256cac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-2/substring-before-2.3.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;
+
+
+{'result1':test."substring-before"('HEllow','HEllow')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.3.query.sqlpp
new file mode 100644
index 0000000..f5d1bcf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring-before-3/substring-before-3.3.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;
+
+
+{'result1':test."substring-before"('HEllow',''),'result2':test."substring-before"('HEllow',null),'result3':test."substring-before"('',null),'result4':test."substring-before"('',''),'result5':test."substring-before"(null,null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.3.query.sqlpp
new file mode 100644
index 0000000..27ff9ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-1/substring2-1.3.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;
+
+
+{'result1':test.substring('HEllow',2)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.3.query.sqlpp
new file mode 100644
index 0000000..271473d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-2/substring2-2.3.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;
+
+
+{'result1':test.substring('HEllow',0)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.3.query.sqlpp
new file mode 100644
index 0000000..eee0126c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-3/substring2-3.3.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;
+
+
+{'result1':test.substring('HEllow',10)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.3.query.sqlpp
new file mode 100644
index 0000000..8ea572c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring2-4/substring2-4.3.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;
+
+
+{'result1':test.substring('HEllow',-1)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.3.query.sqlpp
new file mode 100644
index 0000000..40a6960
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/substring_01/substring_01.3.query.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 element test.substring(x,2,3)
+from  ['foobar'] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.1.ddl.sqlpp
new file mode 100644
index 0000000..8efee57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.1.ddl.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.
+ */
+/*
+ * Testcase Name : toLowerCas02.aql
+ * Description   : Test lowercase(string) function
+ *               : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.2.update.sqlpp
new file mode 100644
index 0000000..8efee57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.2.update.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.
+ */
+/*
+ * Testcase Name : toLowerCas02.aql
+ * Description   : Test lowercase(string) function
+ *               : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.3.query.sqlpp
new file mode 100644
index 0000000..cc112b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase02/toLowerCase02.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Testcase Name : toLowerCas02.aql
+ * Description   : Test lowercase(string) function
+ *               : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+select element a
+from  [lowercase('a   b  c  d  e  f  g'),lowercase('A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'),lowercase('abcdefghij KLMNOP qrstu VWXYZ'),lowercase('abcdefghijklmnopqrstuvwxyz'),lowercase('this is a test string'),lowercase('smaller string'),lowercase('ABCD'),lowercase('AbCdEfGhIjKlMnOpQrStUvWxYz'),lowercase('abcdefghijkABCDEFGHIJK'),lowercase('HIJKLMNOPQRhijklmnopqr'),lowercase(substring('ABCDEFghIJKLMnopQRSTuvwxYZ01234',0)),lowercase('A33B2CD1EF78GHijk123LMNopqrstUVW3x2y01035Z')] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.1.ddl.sqlpp
new file mode 100644
index 0000000..1d43382
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.1.ddl.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.
+ */
+/*
+ * Test case Name : toLowerCas03.aql
+ * Description    : Test lowercase(string) function 
+ *                : This test case covers Positive tests
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  name : string
+}
+
+create  table testds(TestType) primary key name;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.2.update.sqlpp
new file mode 100644
index 0000000..75ede9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.2.update.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.
+ */
+/*
+ * Test case Name : toLowerCas03.aql
+ * Description    : Test lowercase(string) function 
+ *                : This test case covers Positive tests
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+insert into testds
+select element {'name':'Maradona'};
+insert into testds
+select element {'name':'Pele'};
+insert into testds
+select element {'name':'Roberto Baggio'};
+insert into testds
+select element {'name':'Beckham David'};
+insert into testds
+select element {'name':'Rooney'};
+insert into testds
+select element {'name':'Ronaldinho'};
+insert into testds
+select element {'name':'Ronaldo'};
+insert into testds
+select element {'name':'Zinadine Zidane'};
+insert into testds
+select element {'name':'Cristiano Ronaldo'};
+insert into testds
+select element {'name':'Messi'};
+insert into testds
+select element {'name':'Tevez'};
+insert into testds
+select element {'name':'Henry'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.3.query.sqlpp
new file mode 100644
index 0000000..d5c84b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase03/toLowerCase03.3.query.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.
+ */
+/*
+ * Test case Name : toLowerCas03.aql
+ * Description    : Test lowercase(string) function 
+ *                : This test case covers Positive tests
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+use test;
+
+
+select element test.lowercase(l.name)
+from  testds as l
+order by l.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.1.ddl.sqlpp
new file mode 100644
index 0000000..100fd24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.1.ddl.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.
+ */
+/*
+ * Test case Name : toLowerCas04.aql
+ * Description    : Test lowercase(string) function 
+ *                : Convert all upper case english alphabets A-Z to lower case a-z
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.2.update.sqlpp
new file mode 100644
index 0000000..100fd24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.2.update.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.
+ */
+/*
+ * Test case Name : toLowerCas04.aql
+ * Description    : Test lowercase(string) function 
+ *                : Convert all upper case english alphabets A-Z to lower case a-z
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.3.query.sqlpp
new file mode 100644
index 0000000..6a62192
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/toLowerCase04/toLowerCase04.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name : toLowerCas04.aql
+ * Description    : Test lowercase(string) function 
+ *                : Convert all upper case english alphabets A-Z to lower case a-z
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+select element a
+from  [lowercase("codepoint-to-string"([65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90])),lowercase("string-concat"(['ABCDEFGHIJKLMNOP','QRSTUVWXYZ']))] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.3.query.sqlpp
new file mode 100644
index 0000000..cf01d92
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/uppercase/uppercase.3.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;
+
+
+{'result1':test.uppercase('Hellow'),'result2':test.uppercase(''),'result3':test.uppercase(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.3.query.sqlpp
new file mode 100644
index 0000000..194a39b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/01/01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element l
+from  test."subset-collection"([1],0,1) as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.3.query.sqlpp
new file mode 100644
index 0000000..97b0585
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/02/02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element l
+from  test."subset-collection"([1,2,3,4],1,2) as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.3.query.sqlpp
new file mode 100644
index 0000000..c34e01a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/03/03.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element l
+from  test."subset-collection"([1,2,3,4],0,0) as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.3.query.sqlpp
new file mode 100644
index 0000000..7b1bff4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/04/04.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element test."subset-collection"([1,2,3,4],1,2)
+from  [1] as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.3.query.sqlpp
new file mode 100644
index 0000000..ad3bc70
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/05/05.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element l
+from  test."subset-collection"(['a','b','c','d'],1,2) as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.3.query.sqlpp
new file mode 100644
index 0000000..ccd046a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/06/06.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element l
+from  test."subset-collection"([1,2,3,4],2,2) as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.3.query.sqlpp
new file mode 100644
index 0000000..c355c41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/subset-collection/07/07.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+set "import-private-functions" "true";
+
+select element l
+from  test."subset-collection"([1,2,3,4],2,10) as l
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..a3ea6cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ddl.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.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset with indexes.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create temporary table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..4df1b1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset with indexes.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.sqlpp
new file mode 100644
index 0000000..925ae4a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ddl.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.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset with indexes.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+create  index idx_LineItem_partkey  on LineItem (l_linenumber) type btree;
+
+create  index idx_LineItem_suppkey  on LineItem (l_suppkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp
new file mode 100644
index 0000000..d501af7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset with indexes.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+delete l from LineItem
+ where ((l.l_suppkey >= 2) or (l.l_linenumber > 1));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.sqlpp
new file mode 100644
index 0000000..dff3496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.query.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.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset with indexes.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+where (c.l_suppkey < 150)
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..df87619
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ddl.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.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create temporary table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.2.update.sqlpp
new file mode 100644
index 0000000..3b1c9d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.2.update.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.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+delete l from LineItem
+ where (l.l_orderkey >= 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.3.query.sqlpp
new file mode 100644
index 0000000..aa13cc7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.3.query.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.
+ */
+/*
+ * Description     : Delete a portion of data from a loaded temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ddl.sqlpp
new file mode 100644
index 0000000..9caa534
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ddl.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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     : Drop empty secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  first : string,
+  last : string
+}
+
+create type test.Person as
+{
+  name : Name
+}
+
+create type test.TestType as
+{
+  id : int32,
+  name : string,
+  locn : point,
+  zip : string,
+  person : Person
+}
+
+create temporary table t1(TestType) primary key id;
+
+create  index rtree_index_point  on t1 (locn) type rtree;
+
+create  index rtree_index_point_open  on t1 (open_locn:point) type rtree enforced;
+
+create  index keyWD_indx  on t1 (name) type keyword;
+
+create  index keyWD_indx_open  on t1 (nickname:string) type keyword enforced;
+
+create  index secndIndx  on t1 (zip) type btree;
+
+create  index nested  on t1 (person.name.first) type btree;
+
+create  index secndIndx_open  on t1 (address:string) type btree enforced;
+
+drop index t1.rtree_index_point;
+drop index t1.rtree_index_point_open;
+drop index t1.keyWD_indx;
+drop index t1.keyWD_indx_open;
+drop index t1.secndIndx;
+drop index t1.nested;
+drop index t1.secndIndx_open;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.update.sqlpp
new file mode 100644
index 0000000..ebe3e6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.update.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.
+ */
+/*
+ * Description     : Drop empty secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.query.sqlpp
new file mode 100644
index 0000000..9885e87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Drop empty secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+select element l
+from  "Metadata.Index" as l
+where ((l.IsPrimary = false) and (l.DataverseName = 'test'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.1.ddl.sqlpp
new file mode 100644
index 0000000..e06c6af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.1.ddl.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.
+ */
+/*
+ * Description     : Drop secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  unique1 : int64,
+  unique2 : int64,
+  two : int64,
+  four : int64,
+  ten : int64,
+  twenty : int64,
+  onePercent : int64,
+  tenPercent : int64,
+  twentyPercent : int64,
+  fiftyPercent : int64,
+  unique3 : int64,
+  evenOnePercent : int64,
+  oddOnePercent : int64,
+  stringu1 : string,
+  stringu2 : string,
+  string4 : string
+}
+
+create temporary table t1(Schema) primary key unique2;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.2.update.sqlpp
new file mode 100644
index 0000000..f6dc0cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Drop secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+load  table t1 using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/wisc/onektup.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.3.ddl.sqlpp
new file mode 100644
index 0000000..90e6b7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.3.ddl.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.
+ */
+/*
+ * Description     : Drop secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+create  index idx_t1_str1  on t1 (stringu1) type btree;
+
+create  index idx_t1_unique1  on t1 (unique1) type btree;
+
+drop index t1.idx_t1_str1;
+drop index t1.idx_t1_unique1;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.4.query.sqlpp
new file mode 100644
index 0000000..0950324
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/drop-index/drop-index.4.query.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.
+ */
+/*
+ * Description     : Drop secondary indexes for a temporary dataset.
+ * Expected Result : Success
+ * Date            : 27th March 2015
+ *
+ */
+
+use test;
+
+
+select element a
+from  t1 as a
+where ((a.unique1 > 10) and (a.stringu1 = 'DGAAAAXXXXXXXXXXXXXXXXXXX'))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..a7b7c7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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     : Load a temporary dataset with previously created empty indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create temporary table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  index part_index  on LineItem (l_partkey) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.2.update.sqlpp
new file mode 100644
index 0000000..2c84ccd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.2.update.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Load a temporary dataset with previously created empty indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/empty.adm"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.3.query.sqlpp
new file mode 100644
index 0000000..a4c443a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.3.query.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.
+ */
+/*
+ * Description     : Load a temporary dataset with previously created empty indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+select element c
+from  LineItem as c
+order by c.l_orderkey,c.l_linenumber
+limit 1
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.sqlpp
new file mode 100644
index 0000000..2c6e41c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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     : This test is intended to test inserting into a temporary dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+create type test.Emp as
+ closed {
+  id : int64,
+  fname : string,
+  lname : string,
+  age : int64,
+  dept : string
+}
+
+create temporary table test.employee(Emp) primary key id;
+
+create  index idx_employee_first_name  on test.employee (fname) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.update.sqlpp
new file mode 100644
index 0000000..dc07f9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.update.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.
+ */
+/*
+ * Description     : This test is intended to test inserting into a temporary dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : March 28 2015
+ */
+
+use test;
+
+
+load  table test.employee using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+insert into test.employee
+select element {'id':(x.id + 10000),'fname':x.fname,'lname':x.lname,'age':x.age,'dept':x.dept}
+from  "test.employee" as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.query.sqlpp
new file mode 100644
index 0000000..05b5e4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.query.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.
+ */
+/*
+ * Description     : This test is intended to test inserting into a temporary dataset that has a secondary index and scan
+ * the data at the same time where we insert a materializing to prevent the possibility of dead latch.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+select element l
+from  "test.employee" as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.1.ddl.sqlpp
new file mode 100644
index 0000000..70a4ef8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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     : This test is intended to test inserting into a temporary dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : July 11 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.myDataType as
+{
+  id : int64
+}
+
+create temporary table myData(myDataType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.2.update.sqlpp
new file mode 100644
index 0000000..f8f5747
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.2.update.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset.aql
+ * Description     : This test is intended to test inserting into a temporary dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+load  table myData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/odd-numbers.adm"),("format"="adm")) pre-sorted;
+
+insert into myData
+select element {'id':(x.id + 1)}
+from  myData as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.3.query.sqlpp
new file mode 100644
index 0000000..68ccab0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.3.query.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.
+ */
+/* 
+ * Test case Name  : insert-and-scan-dataset.aql
+ * Description     : This test is intended to test inserting into a temporary dataset and scan it at the same time
+ * where we insert a materializing to prevent the possibility of deadlatch.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ *
+ */
+
+use test;
+
+
+select element c
+from  myData as c
+order by c.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..cd43601
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.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.
+ */
+/*
+ * Description     : Test a read query over a temporary dataset.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create temporary table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp
new file mode 100644
index 0000000..73da933
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Test a read query over a temporary dataset.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
new file mode 100644
index 0000000..c9eb48f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.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.
+ */
+/*
+ * Description     : Test a read query over a temporary dataset.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use tpch;
+
+
+set "import-private-functions" "true";
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':tpch.sum((
+        select element i.l_quantity
+        from  l as i
+    )),'sum_base_price':tpch.sum((
+        select element i.l_extendedprice
+        from  l as i
+    )),'sum_disc_price':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount))
+        from  l as i
+    )),'sum_charge':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+        from  l as i
+    )),'ave_qty':tpch.avg((
+        select element i.l_quantity
+        from  l as i
+    )),'ave_price':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'ave_disc':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'count_order':tpch.count(l)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..57b58b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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     : Delete tuples from a temporary dataset with a R-tree index.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create temporary table MyData(MyRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..003b9e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Delete tuples from a temporary dataset with a R-tree index.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..56a3186
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Delete tuples from a temporary dataset with a R-tree index.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+create  index rtree_index_point  on MyData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..ab871bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description     : Delete tuples from a temporary dataset with a R-tree index.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+delete m from MyData
+ where (m.id > 10);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..b7339d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.query.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.
+ */
+/*
+ * Description     : Delete tuples from a temporary dataset with a R-tree index.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.1.ddl.sqlpp
new file mode 100644
index 0000000..817f9cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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     : Port data from a persistent dataset into a temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyMiniRecord as
+ closed {
+  id : int64,
+  point : point
+}
+
+create  table MyData(MyRecord) primary key id;
+
+create temporary table MyMiniData(MyMiniRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.2.update.sqlpp
new file mode 100644
index 0000000..32ecf79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.2.update.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyMiniData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.3.ddl.sqlpp
new file mode 100644
index 0000000..db4816a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.3.ddl.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+create  index rtree_index_point_0  on MyData (point) type rtree;
+
+create  index rtree_index_point  on MyMiniData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.4.update.sqlpp
new file mode 100644
index 0000000..0cf9215
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.4.update.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'id':m.id,'point':m.point}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.5.query.sqlpp
new file mode 100644
index 0000000..37bbc10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.5.query.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp
new file mode 100644
index 0000000..d1b5109
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyMiniRecord as
+ closed {
+  id : int64,
+  point : point
+}
+
+create temporary table MyData(MyRecord) primary key id;
+
+create temporary table MyMiniData(MyMiniRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.sqlpp
new file mode 100644
index 0000000..32ecf79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.update.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyMiniData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.sqlpp
new file mode 100644
index 0000000..db4816a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ddl.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+create  index rtree_index_point_0  on MyData (point) type rtree;
+
+create  index rtree_index_point  on MyMiniData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.sqlpp
new file mode 100644
index 0000000..0cf9215
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.update.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'id':m.id,'point':m.point}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.sqlpp
new file mode 100644
index 0000000..37bbc10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.query.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.1.ddl.sqlpp
new file mode 100644
index 0000000..a4415fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.1.ddl.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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     : Port data from a temporary dataset into a persistent dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int64,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle,
+  circle : circle
+}
+
+create type test.MyMiniRecord as
+ closed {
+  id : int64,
+  point : point
+}
+
+create temporary table MyData(MyRecord) primary key id;
+
+create  table MyMiniData(MyMiniRecord) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.2.update.sqlpp
new file mode 100644
index 0000000..32ecf79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.2.update.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+load  table MyData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load  table MyMiniData using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.3.ddl.sqlpp
new file mode 100644
index 0000000..db4816a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.3.ddl.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+create  index rtree_index_point_0  on MyData (point) type rtree;
+
+create  index rtree_index_point  on MyMiniData (point) type rtree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.4.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.4.update.sqlpp
new file mode 100644
index 0000000..0cf9215
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.4.update.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+insert into MyMiniData
+select element {'id':m.id,'point':m.point}
+from  MyData as m
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.5.query.sqlpp
new file mode 100644
index 0000000..37bbc10
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.5.query.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.
+ */
+/*
+ * Description     : Port data from a temporary dataset into yet-another temporary dataset. 
+ *                   Both datasets have R-tree indexes.
+ * Expected Result : Success
+ * Date            : March 27 2015
+ */
+
+use test;
+
+
+select element {'id':o.id}
+from  MyMiniData as o
+where test."spatial-intersect"(o.point,test."create-polygon"([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]))
+order by o.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.3.query.sqlpp
new file mode 100644
index 0000000..0fac2b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors/accessors.3.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;
+
+
+{'year1':test."get-year"(test.date('2010-10-30')),'year2':test."get-year"(test.datetime('1987-11-19T23:49:23.938')),'year3':test."get-year"(test.date('-1987-11-19')),'year4':test."get-year"(test.date('09280329')),'year5':test."get-year"(test.datetime('19371229T20030628')),'year6':test."get-year"(test.string('-0003-01-09T23:12:12.39-07:00')),'year7':test."get-year"(test.duration('P3Y73M632DT49H743M3948.94S')),'year8':test."get-year"(test."year-month-duration"('P8Y12M')),'year-null':test."get-year"(null),'month1':test."get-month"(test.date('2010-10-30')),'month2':test."get-month"(test.datetime('1987-11-19T23:49:23.938')),'month3':test."get-month"(test.date('-1987-11-19')),'month4':test."get-month"(test.date('09280329')),'month5':test."get-month"(test.datetime('19371229T20030628')),'month6':test."get-month"(test.duration('P3Y73M632DT49H743M3948.94S')),'month7':test."get-month"(test."year-month-duration"('P8Y12M')),'month-null':test."get-month"(null),'day1':test."get-day"(test.date('2010-10-30')),'day2':test."get-day"(test.datetime('1987-11-19T23:49:23.938')),'day3':test."get-day"(test.date('-1987-11-19')),'day4':test."get-day"(test.date('09280329')),'day5':test."get-day"(test.datetime('19371229T20030628')),'day6':test."get-day"(test.duration('P3Y73M632DT49H743M3948.94S')),'day7':test."get-day"(test."day-time-duration"('P32DT49H743M3948.94S')),'day-null':test."get-day"(null),'hour1':test."get-hour"(test.datetime('1987-11-19T23:49:23.938')),'hour2':test."get-hour"(test.datetime('19371229T20030628')),'hour3':test."get-hour"(test.time('12:23:34.930+07:00')),'hour4':test."get-hour"(test.duration('P3Y73M632DT49H743M3948.94S')),'hour5':test."get-hour"(test."day-time-duration"('P32DT49H743M3948.94S')),'hour-null':test."get-hour"(null),'min1':test."get-minute"(test.datetime('1987-11-19T23:49:23.938')),'min2':test."get-minute"(test.datetime('19371229T20030628')),'min3':test."get-minute"(test.time('12:23:34.930+07:00')),'min4':test."get-minute"(test.duration('P3Y73M632DT49H743M3948.94S')),'min5':test."get-minute"(test."day-time-duration"('P32DT49H743M3948.94S')),'min-null':test."get-minute"(null),'second1':test."get-second"(test.datetime('1987-11-19T23:49:23.938')),'second2':test."get-second"(test.datetime('19371229T20030628')),'second3':test."get-second"(test.time('12:23:34.930+07:00')),'second4':test."get-second"(test.duration('P3Y73M632DT49H743M3948.94S')),'second5':test."get-second"(test."day-time-duration"('P32DT49H743M3948.94S')),'second-null':test."get-second"(null),'ms1':test."get-millisecond"(test.datetime('1987-11-19T23:49:23.938')),'ms2':test."get-millisecond"(test.datetime('19371229T20030628')),'ms3':test."get-millisecond"(test.time('12:23:34.930+07:00')),'ms4':test."get-millisecond"(test.duration('P3Y73M632DT49H743M3948.94S')),'ms5':test."get-millisecond"(test."day-time-duration"('P32DT49H743M3948.94S')),'ms-null':test."get-millisecond"(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.3.query.sqlpp
new file mode 100644
index 0000000..4f30c74
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval/accessors_interval.3.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;
+
+
+{'start1':test."get-interval-start"(test."interval-from-date"(test.date('2010-10-30'),'2013-04-01')),'end1':test."get-interval-end"(test."interval-from-date"(test.date('2010-10-30'),'2013-04-01')),'start2':test."get-interval-start"(test."interval-from-time"('08:09:10.234Z',test.time('203040567+0800'))),'end2':test."get-interval-end"(test."interval-from-time"('08:09:10.234Z',test.time('203040567+0800'))),'start3':test."get-interval-start"(test."interval-from-datetime"('2009-09-01T00:00:00.000+08:00',test."datetime-from-date-time"(test.date('2013-04-04'),test.time('00:00:00.000+08:00')))),'end3':test."get-interval-end"(test."interval-from-datetime"('2009-09-01T00:00:00.000+08:00',test."datetime-from-date-time"(test.date('2013-04-04'),test.time('00:00:00.000+08:00'))))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.3.query.sqlpp
new file mode 100644
index 0000000..a79e7d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/accessors_interval_null/accessors_interval_null.3.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;
+
+
+select element {'start-null-interval':test."get-interval-start"(null),'end-null-interval':test."get-interval-end"(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.1.ddl.sqlpp
new file mode 100644
index 0000000..ad5ec6d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check the adjust-timezone functions
+ * Expected Result  :   Success
+ * Date             :   15th Oct, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.3.query.sqlpp
new file mode 100644
index 0000000..7775f62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/adjust_timezone/adjust_timezone.3.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;
+
+
+{'time':test."adjust-time-for-timezone"(test.time('20:15:10.327'),'+0800'),'datetime':test."adjust-datetime-for-timezone"(test.datetime('2010-10-23T01:12:13.329Z'),'-0615'),'null1':test."adjust-time-for-timezone"(null,'+0800'),'null2':test."adjust-time-for-timezone"(test.time('20:15:10.327'),null),'null3':test."adjust-datetime-for-timezone"(null,'-0800'),'null4':test."adjust-datetime-for-timezone"(test.datetime('2010-10-23T01:12:13.329Z'),null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.1.ddl.sqlpp
new file mode 100644
index 0000000..4559b2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32,
+  time : time,
+  date : date,
+  datetime : datetime,
+  dtduration : "day-time-duration",
+  ymduration : "year-month-duration"
+}
+
+create  table tsdata(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.2.update.sqlpp
new file mode 100644
index 0000000..6c68b05
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.2.update.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.
+ */
+
+use test;
+
+
+insert into tsdata
+select element {'id':1,'time':test.time('23:49:23.938'),'date':test.date('1904-01-06'),'datetime':test.datetime('2012-01-12T12:31:39'),'dtduration':test."day-time-duration"('PT5M'),'ymduration':test."year-month-duration"('P5M')};
+insert into tsdata
+select element {'id':2,'time':test.time('12:37:10'),'date':test.date('2194-07-06'),'datetime':test.datetime('2013-01-12T12:31:39'),'dtduration':test."day-time-duration"('PT5.329S'),'ymduration':test."year-month-duration"('P1Y')};
+insert into tsdata
+select element {'id':3,'time':test.time('09:28:10.9'),'date':test.date('-1904-01-06'),'datetime':test.datetime('2012-01-12T18:31:39'),'dtduration':test."day-time-duration"('P3DT2S'),'ymduration':test."year-month-duration"('P29M')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.3.query.sqlpp
new file mode 100644
index 0000000..6c3ed52
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_max/agg_max.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+
+{'m0':test.max((
+    select element i.time
+    from  tsdata as i
+)),'m1':test.max((
+    select element i.date
+    from  tsdata as i
+)),'m2':test.max((
+    select element i.datetime
+    from  tsdata as i
+)),'m3':test.max((
+    select element i.dtduration
+    from  tsdata as i
+)),'m4':test.max((
+    select element i.ymduration
+    from  tsdata as i
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.1.ddl.sqlpp
new file mode 100644
index 0000000..4559b2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.1.ddl.sqlpp
@@ -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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32,
+  time : time,
+  date : date,
+  datetime : datetime,
+  dtduration : "day-time-duration",
+  ymduration : "year-month-duration"
+}
+
+create  table tsdata(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.2.update.sqlpp
new file mode 100644
index 0000000..6c68b05
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.2.update.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.
+ */
+
+use test;
+
+
+insert into tsdata
+select element {'id':1,'time':test.time('23:49:23.938'),'date':test.date('1904-01-06'),'datetime':test.datetime('2012-01-12T12:31:39'),'dtduration':test."day-time-duration"('PT5M'),'ymduration':test."year-month-duration"('P5M')};
+insert into tsdata
+select element {'id':2,'time':test.time('12:37:10'),'date':test.date('2194-07-06'),'datetime':test.datetime('2013-01-12T12:31:39'),'dtduration':test."day-time-duration"('PT5.329S'),'ymduration':test."year-month-duration"('P1Y')};
+insert into tsdata
+select element {'id':3,'time':test.time('09:28:10.9'),'date':test.date('-1904-01-06'),'datetime':test.datetime('2012-01-12T18:31:39'),'dtduration':test."day-time-duration"('P3DT2S'),'ymduration':test."year-month-duration"('P29M')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.3.query.sqlpp
new file mode 100644
index 0000000..08d47ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/agg_min/agg_min.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+
+{'m0':test.min((
+    select element i.time
+    from  tsdata as i
+)),'m1':test.min((
+    select element i.date
+    from  tsdata as i
+)),'m2':test.min((
+    select element i.datetime
+    from  tsdata as i
+)),'m3':test.min((
+    select element i.dtduration
+    from  tsdata as i
+)),'m4':test.min((
+    select element i.ymduration
+    from  tsdata as i
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.1.ddl.sqlpp
new file mode 100644
index 0000000..a4105c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check the calendar-duration functions
+ * Expected Result  :   Success
+ * Date             :   15th Oct, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.3.query.sqlpp
new file mode 100644
index 0000000..91131da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/calendar_duration/calendar_duration.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'cduration1':test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('P7382DT39283M3921.329S')),'c1':((test.datetime('1987-11-19T23:49:23.938') + test.duration('P7382DT39283M3921.329S')) = (test.datetime('1987-11-19T23:49:23.938') + test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('P7382DT39283M3921.329S')))),'cduration2':test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('-PT63H398212M3219.328S')),'c2':((test.datetime('1987-11-19T23:49:23.938') + test.duration('-PT63H398212M3219.328S')) = (test.datetime('1987-11-19T23:49:23.938') + test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('-PT63H398212M3219.328S')))),'cduration3':test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('P1Y90M')),'c3':((test.datetime('1987-11-19T23:49:23.938') + test.duration('P1Y90M')) = (test.datetime('1987-11-19T23:49:23.938') + test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('P1Y90M')))),'cduration4':test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('-P3Y89M4089DT47382.983S')),'c4':((test.datetime('1987-11-19T23:49:23.938') + test.duration('-P3Y89M4089DT47382.983S')) = (test.datetime('1987-11-19T23:49:23.938') + test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),test.duration('-P3Y89M4089DT47382.983S')))),'cduration5':test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('P7382DT39283M3921.329S')),'c5':((test.date('-1328-10-23') + test.duration('P7382DT39283M3921.329S')) = (test.date('-1328-10-23') + test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('P7382DT39283M3921.329S')))),'cduration6':test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('-PT63H398212M3219.328S')),'c6':((test.date('-1328-10-23') + test.duration('-PT63H398212M3219.328S')) = (test.date('-1328-10-23') + test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('-PT63H398212M3219.328S')))),'cduration7':test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('P1Y90M')),'c7':((test.date('-1328-10-23') + test.duration('P1Y90M')) = (test.date('-1328-10-23') + test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('P1Y90M')))),'cduration8':test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('-P3Y89M4089DT47382.983S')),'c8':((test.date('-1328-10-23') + test.duration('-P3Y89M4089DT47382.983S')) = (test.date('-1328-10-23') + test."calendar-duration-from-date"(test.date('-1328-10-23'),test.duration('-P3Y89M4089DT47382.983S')))),'cduration-null-1':test."calendar-duration-from-datetime"(null,test.duration('P7382DT39283M3921.329S')),'cduration-null-2':test."calendar-duration-from-datetime"(test.datetime('1987-11-19T23:49:23.938'),null),'cduration-null-3':test."calendar-duration-from-date"(null,test.duration('P7382DT39283M3921.329S')),'cduration-null-4':test."calendar-duration-from-date"(test.date('-1328-10-23'),null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.1.ddl.sqlpp
new file mode 100644
index 0000000..cedf4bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check temporal functions for date type
+ * Expected Result  :   Success
+ * Date             :   24th Sep, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp
new file mode 100644
index 0000000..e50f88b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'date1':test."date-from-unix-time-in-days"(15600),'date2':test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')),'date3':test."get-date-from-datetime"(test.datetime('2012-10-11T02:30:23+03:00')),'date4':(test."date-from-unix-time-in-days"(15600) + test.duration('-P2Y1M90DT30H')),'date5':(test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')),'duration1':((test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) - test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z'))),'duration2':((test."date-from-unix-time-in-days"(15600) + test.duration('-P2Y1M90DT30H')) - test."date-from-unix-time-in-days"(15600)),'c1':(test."date-from-unix-time-in-days"(15600) = ((test."date-from-unix-time-in-days"(15600) + test.duration('-P2Y1M90DT30H')) + (test."date-from-unix-time-in-days"(15600) - (test."date-from-unix-time-in-days"(15600) + test.duration('-P2Y1M90DT30H'))))),'c2':(test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) = ((test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) + (test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) - (test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M'))))),'null1':test."date-from-unix-time-in-days"(null),'null2':test."get-date-from-datetime"(null),'null3':(null + test.duration('-P2Y1M90DT30H')),'null4':(test."date-from-unix-time-in-days"(15600) + null),'null5':(null - test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z'))),'null6':((test."get-date-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) - null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.1.ddl.sqlpp
new file mode 100644
index 0000000..c6310ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check temporal functions for datetime
+ * Expected Result  :   Success
+ * Date             :   24th Sep, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp
new file mode 100644
index 0000000..b73f4e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'datetime1':test."datetime-from-unix-time-in-ms"(956007429),'datetime1secs':test."datetime-from-unix-time-in-secs"(1356048000),'datetime2':test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')),'datetime3':(test."datetime-from-unix-time-in-ms"(956007429) + (test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test."datetime-from-unix-time-in-ms"(956007429))),'duration1':(test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test."datetime-from-unix-time-in-ms"(956007429)),'c1':(test."datetime-from-unix-time-in-ms"(956007429) = ((test."datetime-from-unix-time-in-ms"(956007429) - (test."datetime-from-unix-time-in-ms"(956007429) + (test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test."datetime-from-unix-time-in-ms"(956007429)))) + (test."datetime-from-unix-time-in-ms"(956007429) + (test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test."datetime-from-unix-time-in-ms"(956007429))))),'null1':test."datetime-from-unix-time-in-ms"(null),'null1secs':test."datetime-from-unix-time-in-secs"(null),'null2':test."datetime-from-date-time"(null,test.time('15:35:49.938-0800')),'null3':test."datetime-from-date-time"(test.date('1327-12-02'),null),'null4':(null - test."datetime-from-unix-time-in-ms"(956007429)),'null5':(test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - null),'null6':(null + (test."datetime-from-date-time"(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test."datetime-from-unix-time-in-ms"(956007429))),'null7':(test."datetime-from-unix-time-in-ms"(956007429) + null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.1.ddl.sqlpp
new file mode 100644
index 0000000..1f76c38
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.1.ddl.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.
+ */
+/**
+ * day-of-week test case: test the day-of-week function
+ * Expected result: success
+ **/
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.2.update.sqlpp
new file mode 100644
index 0000000..a78181c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.2.update.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.
+ */
+/**
+ * day-of-week test case: test the day-of-week function
+ * Expected result: success
+ **/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.3.query.sqlpp
new file mode 100644
index 0000000..c9448d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/day_of_week_01/day_of_week_01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/**
+ * day-of-week test case: test the day-of-week function
+ * Expected result: success
+ **/
+
+use test;
+
+
+{'1970-01-01':test."day-of-week"(test.date('1970-01-01')),'2013-08-06':test."day-of-week"(test.date('2013-08-06')),'-2013-08-06':test."day-of-week"(test.date('-2013-08-06')),'1913-08-06T15:53:28Z':test."day-of-week"(test.datetime('1913-08-06T15:53:28Z')),'-1913-08-10T15:53:28Z':test."day-of-week"(test.datetime('-1913-08-10T15:53:28Z')),'null':test."day-of-week"(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.1.ddl.sqlpp
new file mode 100644
index 0000000..d2a1672
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Test cases for duration comparison functions
+ * Expected Result  :   Success
+ * Date             :   19 Apr, 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.3.query.sqlpp
new file mode 100644
index 0000000..0dee89c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_comps/duration_comps.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'yearMonthGreaterComp':test."year-month-duration-greater-than"(test.duration('P13M'),test.duration('P1Y')),'dayTimeGreaterComp':test."day-time-duration-greater-than"(test.duration('P1D'),test.duration('-P3D')),'yearMonthLessComp':test."year-month-duration-less-than"(test.duration('P13M'),test.duration('P1Y')),'dayTimeLessComp':test."day-time-duration-less-than"(test.duration('P1D'),test.duration('-P3D')),'equal1':test."duration-equal"(test.duration('P1D'),test.duration('PT24H')),'equal2':test."duration-equal"(test.duration('-P3D'),test.duration('PT24H')),'equal3':test."duration-equal"(test."duration-from-months"(test."months-from-year-month-duration"(test."get-year-month-duration"(test.duration('P1Y')))),test.duration('P1Y')),'equal4':test."duration-equal"(test."duration-from-ms"(test."ms-from-day-time-duration"(test."get-day-time-duration"(test.duration('-P3D')))),test.duration('-P3D'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.1.ddl.sqlpp
new file mode 100644
index 0000000..58bdfa7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check temporal functions for duration
+ * Expected Result  :   Success
+ * Date             :   08/22/2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.3.query.sqlpp
new file mode 100644
index 0000000..01a35b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/duration_functions/duration_functions.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description      :   Check temporal functions for duration
+ * Expected Result  :   Success
+ * Date             :   08/22/2013
+ */
+
+use test;
+
+
+{'dr1':test."duration-from-interval"(test."interval-from-date"('2010-10-30','2010-12-21')),'dr2':test."duration-from-interval"(test."interval-from-datetime"('2012-06-26T01:01:01.111','2012-07-27T02:02:02.222')),'dr3':test."duration-from-interval"(test."interval-from-time"('12:32:38','20:29:20')),'dr4':test."duration-from-interval"(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.3.query.sqlpp
new file mode 100644
index 0000000..d27952e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.3.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.
+ */
+/**
+ * get-overlapping-interval test case
+ * Expected result: success
+ **/
+
+select element {'overlap1':"get-overlapping-interval"("interval-from-time"(time('11:23:39'),time('18:27:19')),"interval-from-time"(time('12:23:39'),time('23:18:00'))),'overlap2':"get-overlapping-interval"("interval-from-time"(time('12:23:39'),time('18:27:19')),"interval-from-time"(time('07:19:39'),time('09:18:00'))),'overlap3':"get-overlapping-interval"("interval-from-date"(date('1980-11-30'),date('1999-09-09')),"interval-from-date"(date('2013-01-01'),date('2014-01-01'))),'overlap4':"get-overlapping-interval"("interval-from-date"(date('1980-11-30'),date('2099-09-09')),"interval-from-date"(date('2013-01-01'),date('2014-01-01'))),'overlap5':"get-overlapping-interval"("interval-from-datetime"(datetime('1844-03-03T11:19:39'),datetime('2000-10-30T18:27:19')),"interval-from-datetime"(datetime('1989-03-04T12:23:39'),datetime('2009-10-10T23:18:00'))),'overlap6':"get-overlapping-interval"("interval-from-datetime"(datetime('1989-03-04T12:23:39'),datetime('2000-10-30T18:27:19')),"interval-from-datetime"(datetime('1844-03-03T11:19:39'),datetime('1888-10-10T23:18:00')))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.1.ddl.sqlpp
new file mode 100644
index 0000000..bd98d88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name: date-insert.aql
+ * Description: verify insertion operation for date type
+ * Expected result: success
+ */
+
+drop  database testdvt if exists;
+create  database testdvt;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.2.update.sqlpp
new file mode 100644
index 0000000..c3f88c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.2.update.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 testdvt;
+
+
+create external  table testds(testtype) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/temporal/temporalData.txt"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.3.query.sqlpp
new file mode 100644
index 0000000..e8d9f20
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_delimited_ds/insert_from_delimited_ds.3.query.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 testdvt;
+
+
+select element {'date':r.dateField,'time':r.timeField,'datetime':r.datetimeField,'duration':r.durationField}
+from  testds as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.sqlpp
new file mode 100644
index 0000000..479135c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name: date-insert.aql
+ * Description: verify insertion operation for date type
+ * Expected result: success
+ */
+
+drop  database testdvt if exists;
+create  database testdvt;
+
+use testdvt;
+
+
+create type testdvt.testtype as
+{
+  id : string,
+  dateField : date?,
+  timeField : time?,
+  datetimeField : datetime?,
+  durationField : duration?,
+  intervalField : interval?,
+  yearMonthDurationField : "year-month-duration"?,
+  dayTimeDurationField : "day-time-duration"?
+}
+
+create external  table testds(testtype) using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"(("path"="nc1://data/temporal/temporalData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.sqlpp
new file mode 100644
index 0000000..bf20fd0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.3.query.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 testdvt;
+
+
+select element {'date':r.dateField,'time':r.timeField,'datetime':r.datetimeField,'duration':r.durationField,'interval':r.intervalField,'ymduration':r.yearMonthDurationField,'dtduration':r.dayTimeDurationField}
+from  testds as r
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.ddl.sqlpp
new file mode 100644
index 0000000..f7e92c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/*
+ * Test case name: insert_from_ext_ds_2
+ * Description: verify external data loading on temporal types
+ * Expected result: success
+ */
+
+drop  database timeTest if exists;
+create  database timeTest;
+
+use timeTest;
+
+
+create type timeTest.timesType as
+{
+  date : date,
+  time : time,
+  datetime : datetime,
+  duration : duration,
+  "year-month-duration" : "year-month-duration",
+  "day-time-duration" : "day-time-duration",
+  "date-interval" : interval,
+  "time-interval" : interval,
+  "datetime-interval" : interval
+}
+
+create  table timeData(timesType) primary key date;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.2.update.sqlpp
new file mode 100644
index 0000000..952c467
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.2.update.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 timeTest;
+
+
+load  table timeData using "localfs" (("path"="nc1://data/temporal/simpletemp_30.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.3.query.sqlpp
new file mode 100644
index 0000000..2b73728
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.3.query.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.
+ */
+
+use timeTest;
+
+
+select element r
+from  timeData as r
+order by r.date
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.1.ddl.sqlpp
new file mode 100644
index 0000000..09e53ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.1.ddl.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.
+ */
+/**
+ * Interval_bin test case: test the interval-bin function
+ * Expected result: success
+ **/
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.2.update.sqlpp
new file mode 100644
index 0000000..2eb96a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.2.update.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.
+ */
+/**
+ * Interval_bin test case: test the interval-bin function
+ * Expected result: success
+ **/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.3.query.sqlpp
new file mode 100644
index 0000000..e321629
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin/interval_bin.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin test case: test the interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+{'bin1':test."interval-bin"(test.date('2010-10-30'),test.date('1990-01-01'),test."year-month-duration"('P1Y')),'bin2':test."interval-bin"(test.date('2010-10-30'),test.date('-1990-01-01'),test."year-month-duration"('P1Y')),'bin3':test."interval-bin"(test.datetime('-1987-11-19T23:49:23.938'),test.datetime('1990-01-01T00:00:00.000Z'),test."year-month-duration"('P6M')),'bin4':test."interval-bin"(test.datetime('-1987-11-19T23:49:23.938'),test.datetime('-1990-01-01T00:00:00.000Z'),test."day-time-duration"('PT12H')),'bin5':test."interval-bin"(test.time('12:23:34.930+07:00'),test.time('12:00:00'),test."day-time-duration"('PT2H')),'bin6':test."interval-bin"(null,test.date('-0023-01-01'),test."year-month-duration"('P6M')),'bin7':test."interval-bin"(test.date('2010-10-30'),null,test."year-month-duration"('P6M')),'bin8':test."interval-bin"(test.date('2010-10-30'),test.date('-0023-01-01'),null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ddl.sqlpp
new file mode 100644
index 0000000..bc30e4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ddl.sqlpp
@@ -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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int64,
+  timestamp : datetime
+}
+
+create  table tsdata(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.2.update.sqlpp
new file mode 100644
index 0000000..39790ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.2.update.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+insert into tsdata
+select element {'id':1,'timestamp':test.datetime('-1987-11-19T23:49:23.938')};
+insert into tsdata
+select element {'id':2,'timestamp':test.datetime('-1987-11-20T00:27:13.432')};
+insert into tsdata
+select element {'id':3,'timestamp':test.datetime('-1987-11-18T18:00:00')};
+insert into tsdata
+select element {'id':4,'timestamp':test.datetime('19871119T234923938')};
+insert into tsdata
+select element {'id':5,'timestamp':test.datetime('1987-11-19T23:58:17.038')};
+insert into tsdata
+select element {'id':6,'timestamp':test.datetime('1987-11-19T23:30:00')};
+insert into tsdata
+select element {'id':7,'timestamp':test.datetime('1987-11-19T23:22:38')};
+insert into tsdata
+select element {'id':8,'timestamp':test.datetime('1988-01-21T17:28:13.900')};
+insert into tsdata
+select element {'id':9,'timestamp':test.datetime('-1987-11-19T23:49:23.938')};
+insert into tsdata
+select element {'id':10,'timestamp':test.datetime('-0987-07-01T09:35:28.039')};
+insert into tsdata
+select element {'id':11,'timestamp':test.datetime('2012-11-19T23:49:23.938')};
+insert into tsdata
+select element {'id':12,'timestamp':test.datetime('2013-11-19T23:49:23.938')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.3.query.sqlpp
new file mode 100644
index 0000000..2787866
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+select element {'tbin':d,'count':test.count(i)}
+from  tsdata as i
+group by test."interval-bin"(i.timestamp,test.datetime('1990-01-01T00:00:00.000Z'),test."year-month-duration"('P20Y')) as d
+order by test."get-interval-start"(d)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ddl.sqlpp
new file mode 100644
index 0000000..bc30e4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ddl.sqlpp
@@ -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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int64,
+  timestamp : datetime
+}
+
+create  table tsdata(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.2.update.sqlpp
new file mode 100644
index 0000000..39790ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.2.update.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+insert into tsdata
+select element {'id':1,'timestamp':test.datetime('-1987-11-19T23:49:23.938')};
+insert into tsdata
+select element {'id':2,'timestamp':test.datetime('-1987-11-20T00:27:13.432')};
+insert into tsdata
+select element {'id':3,'timestamp':test.datetime('-1987-11-18T18:00:00')};
+insert into tsdata
+select element {'id':4,'timestamp':test.datetime('19871119T234923938')};
+insert into tsdata
+select element {'id':5,'timestamp':test.datetime('1987-11-19T23:58:17.038')};
+insert into tsdata
+select element {'id':6,'timestamp':test.datetime('1987-11-19T23:30:00')};
+insert into tsdata
+select element {'id':7,'timestamp':test.datetime('1987-11-19T23:22:38')};
+insert into tsdata
+select element {'id':8,'timestamp':test.datetime('1988-01-21T17:28:13.900')};
+insert into tsdata
+select element {'id':9,'timestamp':test.datetime('-1987-11-19T23:49:23.938')};
+insert into tsdata
+select element {'id':10,'timestamp':test.datetime('-0987-07-01T09:35:28.039')};
+insert into tsdata
+select element {'id':11,'timestamp':test.datetime('2012-11-19T23:49:23.938')};
+insert into tsdata
+select element {'id':12,'timestamp':test.datetime('2013-11-19T23:49:23.938')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.3.query.sqlpp
new file mode 100644
index 0000000..050c64d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+select element {'tbin':d,'count':test.count(i)}
+from  tsdata as i
+group by test."interval-bin"(test."get-time-from-datetime"(i.timestamp),test.time('00:00:00.000Z'),test."day-time-duration"('PT10M')) as d
+order by test."get-interval-start"(d)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.1.ddl.sqlpp
new file mode 100644
index 0000000..7802a4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check temporal functions for interval
+ * Expected Result  :   Success
+ * Date             :   2nd Nov, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.3.query.sqlpp
new file mode 100644
index 0000000..e5167ec1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/interval_functions/interval_functions.3.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;
+
+
+{'before1':test."interval-before"(test."interval-from-date"('2010-10-30','2010-12-21'),test."interval-from-date"('2011-10-30','2012-10-21')),'before2':test."interval-before"(test."interval-from-date"('2010-10-30','2010-12-21'),test."interval-from-date"('2010-12-21','2013-01-01')),'after1':test."interval-after"(test."interval-from-date"('2011-10-30','2012-10-21'),test."interval-from-date"('2010-10-30','2010-12-21')),'after2':test."interval-after"(test."interval-from-date"('2010-12-21','2013-01-01'),test."interval-from-date"('2010-10-30','2010-12-21')),'meet1':test."interval-meets"(test."interval-from-datetime"('2012-06-26T01:01:01.111','2012-07-27T02:02:02.222'),test."interval-from-datetime"('20120727T020202222','2013-08-08T03:03:03.333')),'meet2':test."interval-meets"(test."interval-from-datetime"('19000707T020202222','2013-08-07T03:03:03.333'),test."interval-from-datetime"('2012-06-26T01:01:01.111','2012-07-27T02:02:02.222')),'metby1':test."interval-met-by"(test."interval-from-datetime"('20120727T020202222','2013-08-08T03:03:03.333'),test."interval-from-datetime"('2012-06-26T01:01:01.111','2012-07-27T02:02:02.222')),'metby2':test."interval-met-by"(test."interval-from-datetime"('19000707T020202222','2013-08-07T03:03:03.333'),test."interval-from-datetime"('2012-06-26T01:01:01.111','2012-07-27T02:02:02.222')),'overlaps1':test."interval-overlaps"(test."interval-from-time"('12:32:38','20:29:20'),test."interval-from-time"('17:48:19','22:19:49')),'overlaps2':test."interval-overlaps"(test."interval-from-time"('01:32:49','17:48:19'),test."interval-from-time"('17:48:19','22:19:49')),'overlapped1':test."interval-overlapped-by"(test."interval-from-time"('17:48:19','22:19:49'),test."interval-from-time"('12:32:38','20:29:20')),'overlapped2':test."interval-overlapped-by"(test."interval-from-time"('17:48:19','22:19:49'),test."interval-from-time"('01:32:49','17:48:19')),'overlap1':test."interval-overlapping"(test."interval-from-time"('01:32:49','17:48:19'),test."interval-from-time"('12:32:38','20:29:20')),'overlap2':test."interval-overlapping"(test."interval-from-time"('01:32:49','17:48:19'),test."interval-from-time"('17:48:19','22:19:49')),'starts1':test."interval-starts"(test."interval-from-date"('2010-10-30','2010-11-30'),test."interval-from-date"('2010-10-30','2010-12-21')),'starts2':test."interval-starts"(test."interval-from-date"('2010-10-30','2010-11-30'),test."interval-from-date"('2011-10-30','2012-10-21')),'startedby1':test."interval-started-by"(test."interval-from-date"('2010-10-30','2010-12-21'),test."interval-from-date"('2010-10-30','2010-11-30')),'startedby2':test."interval-started-by"(test."interval-from-date"('2010-10-30','2010-11-30'),test."interval-from-date"('2011-10-30','2012-10-21')),'covers1':test."interval-covers"(test."interval-from-date"('2010-10-30','2010-11-30'),test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333')),'covers2':test."interval-covers"(test."interval-from-date"('2010-10-30','2010-11-30'),test."interval-from-datetime"('-19990707T020202222','2013-08-07T03:03:03.333')),'coveredby1':test."interval-covered-by"(test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333'),test."interval-from-date"('2010-10-30','2010-11-30')),'coveredby2':test."interval-covered-by"(test."interval-from-datetime"('-19990707T020202222','2013-08-07T03:03:03.333'),test."interval-from-date"('2010-10-30','2010-11-30')),'ends1':test."interval-ends"(test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333'),test."interval-from-time"('12:32:38','20:29:20')),'ends2':test."interval-ends"(test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333'),test."interval-from-time"('17:48:19','22:19:49')),'endedby1':test."interval-ended-by"(test."interval-from-time"('12:32:38','20:29:20'),test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333')),'endedby2':test."interval-ended-by"(test."interval-from-time"('17:48:19','22:19:49'),test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333')),'null1':test."interval-before"(null,test."interval-from-date"('2011-10-30','2012-10-21')),'null2':test."interval-covered-by"(test."interval-from-datetime"('19990707T020202222','2013-08-07T03:03:03.333'),null),'null3':test."interval-overlapping"(null,null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.1.ddl.sqlpp
new file mode 100644
index 0000000..bc3ec46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.1.ddl.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.
+ */
+/**
+ * overlap_bins test case: test the overlap_bins
+ * Expected result: success
+ **/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.2.update.sqlpp
new file mode 100644
index 0000000..bc3ec46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.2.update.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.
+ */
+/**
+ * overlap_bins test case: test the overlap_bins
+ * Expected result: success
+ **/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.3.query.sqlpp
new file mode 100644
index 0000000..fa484e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins/overlap_bins.3.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.
+ */
+/**
+ * overlap_bins test case: test the overlap_bins
+ * Expected result: success
+ **/
+
+{'timebins':"overlap-bins"("interval-from-time"(time('17:23:37'),time('18:30:21')),time('00:00:00'),"day-time-duration"('PT30M')),'datebins':"overlap-bins"("interval-from-date"(date('1984-03-17'),date('2013-08-22')),date('1990-01-01'),"year-month-duration"('P20Y')),'datetimebins':"overlap-bins"("interval-from-datetime"(datetime('1800-01-01T23:59:48.938'),datetime('2015-07-26T13:28:30.218')),datetime('1900-01-01T00:00:00.000'),"year-month-duration"('P100Y'))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ddl.sqlpp
new file mode 100644
index 0000000..30485cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32,
+  time : time,
+  duration : "day-time-duration"
+}
+
+create  table tsdata(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.update.sqlpp
new file mode 100644
index 0000000..d62ea96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.update.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+insert into tsdata
+select element {'id':1,'time':test.time('23:49:23.938'),'duration':test."day-time-duration"('PT5M')};
+insert into tsdata
+select element {'id':2,'time':test.time('00:27:13.432'),'duration':test."day-time-duration"('PT1H')};
+insert into tsdata
+select element {'id':3,'time':test.time('18:00:00'),'duration':test."day-time-duration"('PT2H')};
+insert into tsdata
+select element {'id':4,'time':test.time('234933938'),'duration':test."day-time-duration"('PT30S')};
+insert into tsdata
+select element {'id':5,'time':test.time('23:58:17.038'),'duration':test."day-time-duration"('PT39.382S')};
+insert into tsdata
+select element {'id':6,'time':test.time('23:30:00'),'duration':test."day-time-duration"('PT2M')};
+insert into tsdata
+select element {'id':7,'time':test.time('23:22:38'),'duration':test."day-time-duration"('PT20M')};
+insert into tsdata
+select element {'id':8,'time':test.time('17:28:13.900'),'duration':test."day-time-duration"('PT19S')};
+insert into tsdata
+select element {'id':9,'time':test.time('07:49:23.938'),'duration':test."day-time-duration"('PT3H')};
+insert into tsdata
+select element {'id':10,'time':test.time('09:35:28.039'),'duration':test."day-time-duration"('PT10H50M')};
+insert into tsdata
+select element {'id':11,'time':test.time('12:49:23.938'),'duration':test."day-time-duration"('PT3H')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.query.sqlpp
new file mode 100644
index 0000000..2fa66bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.query.sqlpp
@@ -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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+select element {'tbin':gen0.bin,'interval':itv,'overlap':test."get-overlapping-interval"(gen0.bin,itv)}
+from
+    ( select element {'i':i,'bin':bin}
+      from  tsdata as i,
+            test."overlap-bins"(test."interval-start-from-time"(i.time,i.duration),test.time('00:00:00'),test."day-time-duration"('PT1H30M')) as j
+      group by j as bin
+      order by test."get-interval-start"(bin)
+    ) as gen0,
+    gen0.i as x
+with itv as test."interval-start-from-time"(x.time,x.duration)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ddl.sqlpp
new file mode 100644
index 0000000..30485cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Schema as
+ closed {
+  id : int32,
+  time : time,
+  duration : "day-time-duration"
+}
+
+create  table tsdata(Schema) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.update.sqlpp
new file mode 100644
index 0000000..d62ea96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.update.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+insert into tsdata
+select element {'id':1,'time':test.time('23:49:23.938'),'duration':test."day-time-duration"('PT5M')};
+insert into tsdata
+select element {'id':2,'time':test.time('00:27:13.432'),'duration':test."day-time-duration"('PT1H')};
+insert into tsdata
+select element {'id':3,'time':test.time('18:00:00'),'duration':test."day-time-duration"('PT2H')};
+insert into tsdata
+select element {'id':4,'time':test.time('234933938'),'duration':test."day-time-duration"('PT30S')};
+insert into tsdata
+select element {'id':5,'time':test.time('23:58:17.038'),'duration':test."day-time-duration"('PT39.382S')};
+insert into tsdata
+select element {'id':6,'time':test.time('23:30:00'),'duration':test."day-time-duration"('PT2M')};
+insert into tsdata
+select element {'id':7,'time':test.time('23:22:38'),'duration':test."day-time-duration"('PT20M')};
+insert into tsdata
+select element {'id':8,'time':test.time('17:28:13.900'),'duration':test."day-time-duration"('PT19S')};
+insert into tsdata
+select element {'id':9,'time':test.time('07:49:23.938'),'duration':test."day-time-duration"('PT3H')};
+insert into tsdata
+select element {'id':10,'time':test.time('09:35:28.039'),'duration':test."day-time-duration"('PT10H50M')};
+insert into tsdata
+select element {'id':11,'time':test.time('12:49:23.938'),'duration':test."day-time-duration"('PT3H')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.query.sqlpp
new file mode 100644
index 0000000..86fc34a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.query.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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use test;
+
+
+select element {'timebin':bin,'count':test.count(i2),'total_ms':test.sum((
+        select element test."ms-from-day-time-duration"(test."duration-from-interval"(test."get-overlapping-interval"(bin,i3.interval)))
+        from  i2 as i3
+    ))}
+from  (
+    select element {'interval':test."interval-start-from-time"(i1.time,i1.duration)}
+    from  tsdata as i1
+    order by i1.time
+) as i2,
+      test."overlap-bins"(i2.interval,test.time('00:00:00'),test."day-time-duration"('PT1H30M')) as j
+group by j as bin
+order by test."get-interval-start"(bin)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ddl.sqlpp
new file mode 100644
index 0000000..1cc7f90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ddl.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.
+ */
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop  database multitask if exists;
+create  database multitask;
+
+use multitask;
+
+
+create type multitask.LogType as
+ closed {
+  row_id : int32,
+  time : time,
+  duration : int32,
+  app : string
+}
+
+create  table logs(LogType) primary key row_id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.update.sqlpp
new file mode 100644
index 0000000..f33e36b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.update.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 multitask;
+
+
+insert into logs
+select element {'row_id':1,'time':multitask.time('10:27:12'),'duration':5,'app':'Facebook'};
+insert into logs
+select element {'row_id':2,'time':multitask.time('10:27:18'),'duration':6,'app':'Email'};
+insert into logs
+select element {'row_id':3,'time':multitask.time('10:27:25'),'duration':26,'app':'Facebook'};
+insert into logs
+select element {'row_id':4,'time':multitask.time('10:27:52'),'duration':19,'app':'Email'};
+insert into logs
+select element {'row_id':5,'time':multitask.time('10:28:12'),'duration':47,'app':'Facebook'};
+insert into logs
+select element {'row_id':6,'time':multitask.time('10:29:00'),'duration':33,'app':'Email'};
+insert into logs
+select element {'row_id':7,'time':multitask.time('10:29:10'),'duration':18,'app':'Facebook'};
+insert into logs
+select element {'row_id':8,'time':multitask.time('10:29:29'),'duration':159,'app':'Facebook'};
+insert into logs
+select element {'row_id':9,'time':multitask.time('11:07:15'),'duration':30,'app':'Email'};
+insert into logs
+select element {'row_id':10,'time':multitask.time('11:07:47'),'duration':31,'app':'Email'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.query.sqlpp
new file mode 100644
index 0000000..cfce69e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 multitask;
+
+
+select element {'timebin':bin,'subgroups':(
+        select element {'subgid':subgid,'item_count':multitask.count(i)}
+        from  logs as i
+        where multitask."interval-covers"(bin,multitask."interval-start-from-time"(i.time,multitask."duration-from-ms"(i.duration)))
+        group by i.app as subgid
+        order by subgid,multitask.count(i)
+    )}
+from  multitask."overlap-bins"(multitask."interval-from-time"(multitask.min((
+    select element i.time
+    from  logs as i
+)),multitask.max((
+    select element (i.time + multitask."duration-from-ms"((i.duration * 1000)))
+    from  logs as i
+))),multitask.time('00:00:00.000'),multitask."day-time-duration"('PT1M')) as bin
+order by multitask."get-interval-start"(bin)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.1.ddl.sqlpp
new file mode 100644
index 0000000..a83dba7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.1.ddl.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.
+ */
+/**
+ * Test case for parsing temporal strings with format strings
+ * Expected Result: Success
+ **/
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.2.update.sqlpp
new file mode 100644
index 0000000..a760390
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.2.update.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.
+ */
+/**
+ * Test case for parsing temporal strings with format strings
+ * Expected Result: Success
+ **/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.3.query.sqlpp
new file mode 100644
index 0000000..a5e7088
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_01/parse_01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/**
+ * Test case for parsing temporal strings with format strings
+ * Expected Result: Success
+ **/
+
+use test;
+
+
+select element {'date1':test."parse-date"('2013-8-23','YY-M-D'),'date2':test."parse-date"('Aug 12 -12','MMM D Y'),'date3':test."parse-date"('-1234-01-01','YYYY-MM-DD'),'date4':test."parse-date"('09/11/-1980','D/M/Y'),'date5':test."parse-date"('09/11/-1990','YY-M-D|MMM D Y|D/M/Y'),'date6':test."parse-date"('Mon Aug 19 2013','W MMM D Y'),'data7':test."parse-date"('SKIPMEPLEASE Mon Aug SKIPME1ALSO 19 2013','O W MMM O D Y'),'time1':test."parse-time"('8:23:49','h:m:s'),'time2':test."parse-time"('8.19.23:32','h.m.s:nn'),'time3':test."parse-time"('08.19.23:32 pm','h.m.s:nn a'),'time4':test."parse-time"('6:30:40.948 pm PST','h:mm:ss.nnn a z'),'time5':test."parse-time"('6:30:40.948 pm PST','h:m:s|h.m.s:nn|h.m.s:nn a|h:mm:ss.nnn a z'),'datetime1':test."parse-datetime"('Dec 30 -1203 3:48:27 PM','MMM DD YYYY h:m:s a'),'datetime2':test."parse-datetime"('12/30/-1203 03:48:27.392 PM Asia/Shanghai','MM/DD/YYY hh:mm:ss.nnn a z'),'datetime3':test."parse-datetime"('1723-12-03T23:59:23.392Z','YYYY-MM-DDThh:mm:ss.nnnz'),'datetime4':test."parse-datetime"('1723-12-03T23:59:23.392-04:00','YYYY-MM-DDThh:mm:ss.nnnz'),'datetime5':test."parse-datetime"('1723-12-03T23:59:23.392-04:00','MMM DD YYYY h:m:s a|MM/DD/YYY hh:mm:ss.nnn a z|YYYY-MM-DDThh:mm:ss.nnnz'),'datetime6':test."parse-datetime"('1970-01-01 Thu 23:59:23.392-04:00','MMM DD YYYY h:m:s a|MM/DD/YYY hh:mm:ss.nnn a z|YYYY-MM-DD W hh:mm:ss.nnnz'),'datetime7':test."parse-datetime"('1723-12-03 What3v3r STRINGHERE 23:59:23.392-04:00','MMM DD YYYY h:m:s a|MM/DD/YYY hh:mm:ss.nnn a z|YYYY-MM-DD O O hh:mm:ss.nnnz')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.1.ddl.sqlpp
new file mode 100644
index 0000000..a83dba7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.1.ddl.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.
+ */
+/**
+ * Test case for parsing temporal strings with format strings
+ * Expected Result: Success
+ **/
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.2.update.sqlpp
new file mode 100644
index 0000000..a760390
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.2.update.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.
+ */
+/**
+ * Test case for parsing temporal strings with format strings
+ * Expected Result: Success
+ **/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.3.query.sqlpp
new file mode 100644
index 0000000..a6f8354
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/parse_02/parse_02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/**
+ * Test case for parsing temporal strings with format strings
+ * Expected Result: Success
+ **/
+
+use test;
+
+
+{'date-string-1':test."print-date"(test.date('-0123-01-30'),'YY/M/D'),'date-string-2':test."print-date"(test.date('-0123-01-30'),'MMM DD, YYYY'),'date-string-3':test."print-date"(test.date('-0123-01-30'),'YYYY/MM/DD'),'time-string-1':test."print-time"(test.time('08:07:29.030Z'),'h.m.s.nn a z'),'time-string-2':test."print-time"(test.time('08:07:29.030Z'),'hh.mm.ss.nnn a z'),'datetime-string-1':test."print-datetime"(test.datetime('0137-12-31T23:59:59.999+08:00'),'MMM DD h:m:s.nnn a YY z'),'datetime-string-2':test."print-datetime"(test.datetime('0137-12-31T23:59:59.999+08:00'),'YYYY/MMM/DD h:m:s.nnnz a'),'datetime-string-3':test."print-datetime"(test.datetime('0137-12-31T23:59:59.999+08:00'),'YYYY-MM-DDThh:mm:ss.nnnz')};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.1.ddl.sqlpp
new file mode 100644
index 0000000..3a31488
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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      :   Check temporal functions for time
+ * Expected Result  :   Success
+ * Date             :   24th Sep, 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp
new file mode 100644
index 0000000..dd0d9eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.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;
+
+
+set "import-private-functions" "true";
+
+{'time1':test."time-from-unix-time-in-ms"(1560074),'time2':test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')),'time3':test."get-time-from-datetime"(test.datetime('2012-10-11T02:30:23+03:00')),'time4':(test."time-from-unix-time-in-ms"(1560074) + test."day-time-duration"('-PT30H')),'time5':(test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test."day-time-duration"('PT36M')),'duration1':((test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test."day-time-duration"('PT36M')) - test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z'))),'duration2':((test."time-from-unix-time-in-ms"(1560074) + test."day-time-duration"('-PT30H')) - test."time-from-unix-time-in-ms"(1560074)),'c1':(test."time-from-unix-time-in-ms"(1560074) = ((test."time-from-unix-time-in-ms"(1560074) - (test."time-from-unix-time-in-ms"(1560074) + test."day-time-duration"('-PT30H'))) + (test."time-from-unix-time-in-ms"(1560074) + test."day-time-duration"('-PT30H')))),'c2':(test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) = ((test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test."day-time-duration"('PT36M')) + (test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) - (test."get-time-from-datetime"(test.datetime('1327-12-02T23:35:49.938Z')) + test."day-time-duration"('PT36M'))))),'null1':test."time-from-unix-time-in-ms"(null),'null2':test."get-time-from-datetime"(null),'null3':(null + test."day-time-duration"('-PT30H')),'null4':(test."time-from-unix-time-in-ms"(1560074) + null),'null5':(null - test."time-from-unix-time-in-ms"(1560074)),'null6':((test."time-from-unix-time-in-ms"(1560074) + test."day-time-duration"('-PT30H')) - null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.1.ddl.sqlpp
new file mode 100644
index 0000000..8bd624d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.1.ddl.sqlpp
@@ -0,0 +1,71 @@
+/*
+ * 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 TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.TwitterUserType as
+{
+  "screen-name" : string,
+  lang : string,
+  friends_count : int64,
+  statuses_count : int64,
+  name : string,
+  followers_count : int64
+}
+
+create type TinySocial.TweetMessageType as
+ closed {
+  tweetid : string,
+  user : TwitterUserType,
+  "sender-location" : point?,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create type TinySocial.EmploymentType as
+{
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type TinySocial.FacebookUserType as
+ closed {
+  id : int64,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "friend-ids" : {{int64}},
+  employment : [EmploymentType]
+}
+
+create type TinySocial.FacebookMessageType as
+ closed {
+  "message-id" : int64,
+  "author-id" : int64,
+  "in-response-to" : int64?,
+  "sender-location" : point?,
+  message : string
+}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.10.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.10.query.sqlpp
new file mode 100644
index 0000000..1e61279
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.10.query.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.
+ */
+/**
+* Query 4 - Theta Join
+*/
+
+use TinySocial;
+
+
+select element {'message':t."message-text",'nearby-messages':(
+        select element {'msgtxt':t2."message-text"}
+        from  TweetMessages as t2
+        where (TinySocial."spatial-distance"(t."sender-location",t2."sender-location") <= 1)
+        order by t2."message-text"
+    )}
+from  TweetMessages as t
+order by t."message-text"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.11.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.11.query.sqlpp
new file mode 100644
index 0000000..8783e8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.11.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/**
+* Query 5 - Fuzzy Join 
+*/
+
+use TinySocial;
+
+
+set "simfunction" "edit-distance";
+
+set "simthreshold" "3";
+
+select element {'id':fbu.id,'name':fbu.name,'similar-users':(
+        select element {'twitter-screenname':tu."screen-name",'twitter-name':tu.name}
+        from  TweetMessages as t
+        with  tu as t.user
+        where (tu.name ~= fbu.name)
+    )}
+from  FacebookUsers as fbu
+order by fbu.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.query.sqlpp
new file mode 100644
index 0000000..c4119f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 6 - Existential Quantification
+*/
+
+use TinySocial;
+
+
+select element fbu
+from  FacebookUsers as fbu
+where some e in fbu.employment satisfies TinySocial."is-null"(e."end-date")
+order by fbu.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.query.sqlpp
new file mode 100644
index 0000000..5611b99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 7 - Universal Quantification
+*/
+
+use TinySocial;
+
+
+select element fbu
+from  FacebookUsers as fbu
+where every e in fbu.employment satisfies TinySocial.not(TinySocial."is-null"(e."end-date"))
+order by fbu.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.14.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.14.query.sqlpp
new file mode 100644
index 0000000..5770a46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.14.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 8 - Simple Aggregation
+*/
+
+use TinySocial;
+
+
+select element TinySocial.count((
+    select element fbu
+    from  FacebookUsers as fbu
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.15.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.15.query.sqlpp
new file mode 100644
index 0000000..be27270
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.15.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 9-A - Grouping and Aggregation
+*/
+
+use TinySocial;
+
+
+select element {'user':uid,'count':TinySocial.count(t)}
+from  TweetMessages as t
+group by t.user."screen-name" as uid
+order by uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.16.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.16.query.sqlpp
new file mode 100644
index 0000000..17f71c4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.16.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 9-B - (Hash-Based) Grouping and Aggregation
+*/
+
+use TinySocial;
+
+
+select element {'user':uid,'count':TinySocial.count(t)}
+from  TweetMessages as t
+/* +hash */
+group by t.user."screen-name" as uid
+order by uid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.17.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.17.query.sqlpp
new file mode 100644
index 0000000..86aadfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.17.query.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.
+ */
+/**
+* Query 10 - Grouping and Limits
+*/
+
+use TinySocial;
+
+
+select element {'user':uid,'count':c}
+from  TweetMessages as t
+group by t.user."screen-name" as uid
+with  c as TinySocial.count(t)
+order by c,uid desc
+limit 3
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.18.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.18.query.sqlpp
new file mode 100644
index 0000000..67abd9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.18.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+/**
+* Query 11 - Left Outer Fuzzy Join
+*/
+
+use TinySocial;
+
+
+set "simfunction" "jaccard";
+
+set "simthreshold" "0.3";
+
+select element {'tweet':t,'similar-tweets':(
+        select element t2."referred-topics"
+        from  TweetMessages as t2
+        where ((t2."referred-topics" ~= t."referred-topics") and (t2.tweetid != t.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t
+order by t.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.19.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.19.update.sqlpp
new file mode 100644
index 0000000..64c730e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.19.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/**
+* Inserting New Data
+*/
+
+use TinySocial;
+
+
+insert into TweetMessages
+select element {'tweetid':'13','user':{'screen-name':'NathanGiesen@211','lang':'en','friends_count':39345,'statuses_count':479,'name':'Nathan Giesen','followers_count':49420},'sender-location':TinySocial.point('47.44,80.65'),'send-time':TinySocial.datetime('2008-04-26T10:10:35'),'referred-topics':{{'tweeting'}},'message-text':'tweety tweet, my fellow tweeters!'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.2.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.2.ddl.sqlpp
new file mode 100644
index 0000000..37b5ae3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.2.ddl.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 TinySocial;
+
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  table TwitterUsers(TwitterUserType) primary key "screen-name";
+
+create  table TweetMessages(TweetMessageType) primary key tweetid hints ("CARDINALITY"="100");
+
+create  index fbUserSinceIdx  on FacebookUsers ("user-since") type btree;
+
+create  index fbAuthorIdx  on FacebookMessages ("author-id") type btree;
+
+create  index fbSenderLocIndex  on FacebookMessages ("sender-location") type rtree;
+
+create  index fbMessageIdx  on FacebookMessages (message) type keyword;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.20.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.20.query.sqlpp
new file mode 100644
index 0000000..0d8d574
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.20.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Inserting New Data - Verification
+*/
+
+use TinySocial;
+
+
+select element t
+from  TweetMessages as t
+order by t.tweetid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.21.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.21.update.sqlpp
new file mode 100644
index 0000000..21f2b22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.21.update.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/**
+* Deleting Existing Data
+*/
+
+use TinySocial;
+
+
+delete tm from TweetMessages
+ where (tm.tweetid = '13');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.22.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.22.query.sqlpp
new file mode 100644
index 0000000..559658c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.22.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Deleting Existing Data - Verification
+*/
+
+use TinySocial;
+
+
+select element TinySocial.count((
+    select element t
+    from  TweetMessages as t
+    where (t.tweetid = '13')
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.3.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.3.update.sqlpp
new file mode 100644
index 0000000..b366ad7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.3.update.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.
+ */
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
+load  table TwitterUsers using "localfs" (("path"="nc1://data/tinysocial/twu.adm"),("format"="adm"));
+
+load  table TweetMessages using "localfs" (("path"="nc1://data/tinysocial/twm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.4.query.sqlpp
new file mode 100644
index 0000000..33fc78b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.4.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 0-A - Exact-Match Lookup
+*/
+
+use TinySocial;
+
+
+select element user
+from  FacebookUsers as user
+where (user.id = 8)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.5.query.sqlpp
new file mode 100644
index 0000000..98c5c5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.5.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 0-B - Range Scan
+*/
+
+use TinySocial;
+
+
+select element user
+from  FacebookUsers as user
+where ((user.id >= 2) and (user.id <= 4))
+order by user.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.6.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.6.query.sqlpp
new file mode 100644
index 0000000..ae35240
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.6.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 1 - Other Query Filters 
+*/
+
+use TinySocial;
+
+
+select element user
+from  FacebookUsers as user
+where ((user."user-since" >= TinySocial.datetime('2010-07-22T00:00:00')) and (user."user-since" <= TinySocial.datetime('2012-07-29T23:59:59')))
+order by user.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.7.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.7.query.sqlpp
new file mode 100644
index 0000000..f6720c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.7.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 2-A - Equijoin
+*/
+
+use TinySocial;
+
+
+select element {'uname':user.name,'message':message.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where (message."author-id" = user.id)
+order by user.name,message."message-id"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.8.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.8.query.sqlpp
new file mode 100644
index 0000000..1dd4b35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.8.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+* Query 2-B - Index join
+*/
+
+use TinySocial;
+
+
+select element {'uname':user.name,'message':message.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where (message."author-id" /*+ indexnl */  = user.id)
+order by user.name,message."message-id"
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.9.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.9.query.sqlpp
new file mode 100644
index 0000000..a81d88d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.9.query.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.
+ */
+/**
+* Query 3 - Nested Outer Join
+*/
+
+use TinySocial;
+
+
+select element {'uname':user.name,'messages':(
+        select element message.message
+        from  FacebookMessages as message
+        where (message."author-id" = user.id)
+        order by message."message-id"
+    )}
+from  FacebookUsers as user
+order by user.name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.sqlpp
new file mode 100644
index 0000000..428787c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Jürgen S. Generic\'s Car',
+      tokens as test."counthashed-gram-tokens"(txt,3,false)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.sqlpp
new file mode 100644
index 0000000..2a746a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Jürgen S. Generic\'s Car',
+      tokens as test."counthashed-gram-tokens"(txt,3,true)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.sqlpp
new file mode 100644
index 0000000..de22aef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen.',
+      tokens as test."counthashed-word-tokens"(txt)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.3.query.sqlpp
new file mode 100644
index 0000000..e98d084
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Jürgen S. Generic\'s Car',
+      tokens as test."gram-tokens"(txt,3,false)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.3.query.sqlpp
new file mode 100644
index 0000000..3ab8a44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Jürgen S. Generic\'s Car',
+      tokens as test."gram-tokens"(txt,3,true)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.sqlpp
new file mode 100644
index 0000000..6075f13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Jürgen S. Generic\'s Car',
+      tokens as test."hashed-gram-tokens"(txt,3,false)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.sqlpp
new file mode 100644
index 0000000..09ea6aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Jürgen S. Generic\'s Car',
+      tokens as test."hashed-gram-tokens"(txt,3,true)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.sqlpp
new file mode 100644
index 0000000..71fb6a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+with  txt as 'Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen.',
+      tokens as test."hashed-word-tokens"(txt)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.3.query.sqlpp
new file mode 100644
index 0000000..122a992
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_01/word-tokens_01.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+with  txt as 'Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen.',
+      tokens as test."word-tokens"(txt)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.1.ddl.sqlpp
new file mode 100644
index 0000000..4cac12b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.3.query.sqlpp
new file mode 100644
index 0000000..7865f85b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tokenizers/word-tokens_02/word-tokens_02.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+with  txt as 'ΩΣ',
+      tokens as test."word-tokens"(txt)
+select element token
+from  tokens as token
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..8649a3b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp
new file mode 100644
index 0000000..2c89045
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
new file mode 100644
index 0000000..94b313f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.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.
+ */
+
+use tpch;
+
+
+set "import-private-functions" "true";
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':tpch.sum((
+        select element i.l_quantity
+        from  l as i
+    )),'sum_base_price':tpch.sum((
+        select element i.l_extendedprice
+        from  l as i
+    )),'sum_disc_price':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount))
+        from  l as i
+    )),'sum_charge':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+        from  l as i
+    )),'ave_qty':tpch.avg((
+        select element i.l_quantity
+        from  l as i
+    )),'ave_price':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'ave_disc':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'count_order':tpch.count(l)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
new file mode 100644
index 0000000..a55c74d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp1() {
+(
+    select element {'s_acctbal':pssrn.s_acctbal,'s_name':pssrn.s_name,'n_name':pssrn.n_name,'p_partkey':p.p_partkey,'ps_supplycost':pssrn.ps_supplycost,'p_mfgr':p.p_mfgr,'s_address':pssrn.s_address,'s_phone':pssrn.s_phone,'s_comment':pssrn.s_comment}
+    from  Part as p,
+          (
+        select element {'n_name':srn.n_name,'p_partkey':ps.ps_partkey,'ps_supplycost':ps.ps_supplycost,'s_name':srn.s_name,'s_acctbal':srn.s_acctbal,'s_address':srn.s_address,'s_phone':srn.s_phone,'s_comment':srn.s_comment}
+        from  Partsupp as ps,
+              (
+            select element {'s_suppkey':s.s_suppkey,'n_name':rn.n_name,'s_name':s.s_name,'s_acctbal':s.s_acctbal,'s_address':s.s_address,'s_phone':s.s_phone,'s_comment':s.s_comment}
+            from  Supplier as s,
+                  (
+                select element {'n_nationkey':n.n_nationkey,'n_name':n.n_name}
+                from  Region as r,
+                      Nation as n
+                where ((n.n_regionkey = r.r_regionkey) and (r.r_name = 'EUROPE'))
+            ) as rn
+            where (s.s_nationkey = rn.n_nationkey)
+        ) as srn
+        where (srn.s_suppkey = ps.ps_suppkey)
+    ) as pssrn
+    where ((p.p_partkey = pssrn.p_partkey) and tpch.like(p.p_type,'%BRASS'))
+)
+};
+declare function tmp2() {
+(
+    select element {'p_partkey':p_partkey,'ps_min_supplycost':tpch.min((
+            select element i.ps_supplycost
+            from  pssrn as i
+        ))}
+    from  Part as p,
+          (
+        select element {'n_name':srn.n_name,'p_partkey':ps.ps_partkey,'ps_supplycost':ps.ps_supplycost,'s_name':srn.s_name,'s_acctbal':srn.s_acctbal,'s_address':srn.s_address,'s_phone':srn.s_phone,'s_comment':srn.s_comment}
+        from  Partsupp as ps,
+              (
+            select element {'s_suppkey':s.s_suppkey,'n_name':rn.n_name,'s_name':s.s_name,'s_acctbal':s.s_acctbal,'s_address':s.s_address,'s_phone':s.s_phone,'s_comment':s.s_comment}
+            from  Supplier as s,
+                  (
+                select element {'n_nationkey':n.n_nationkey,'n_name':n.n_name}
+                from  Region as r,
+                      Nation as n
+                where ((n.n_regionkey = r.r_regionkey) and (r.r_name = 'EUROPE'))
+            ) as rn
+            where (s.s_nationkey = rn.n_nationkey)
+        ) as srn
+        where (srn.s_suppkey = ps.ps_suppkey)
+    ) as pssrn
+    where ((p.p_partkey = pssrn.p_partkey) and tpch.like(p.p_type,'%BRASS'))
+    /* +hash */
+    group by pssrn.p_partkey as p_partkey
+)
+};
+select element {'s_acctbal':t1.s_acctbal,'s_name':t1.s_name,'n_name':t1.n_name,'p_partkey':t1.p_partkey,'p_mfgr':t1.p_mfgr,'s_address':t1.s_address,'s_phone':t1.s_phone,'s_comment':t1.s_comment}
+from  tpch.tmp2() as t2,
+      tpch.tmp1() as t1
+where ((t1.p_partkey = t2.p_partkey) and (t1.ps_supplycost = t2.ps_min_supplycost))
+order by t1.s_acctbal desc,t1.n_name,t1.s_name,t1.p_partkey
+limit 100
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.sqlpp
new file mode 100644
index 0000000..a9495c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.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.
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
new file mode 100644
index 0000000..d30c6d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 tpch;
+
+
+select element {'l_orderkey':l_orderkey,'revenue':revenue,'o_orderdate':o_orderdate,'o_shippriority':o_shippriority}
+from  Customer as c,
+      Orders as o,
+      LineItem as l
+where (((c.c_mktsegment = 'BUILDING') and (c.c_custkey = o.o_custkey)) and ((l.l_orderkey = o.o_orderkey) and (o.o_orderdate < '1995-03-15') and (l.l_shipdate > '1995-03-15')))
+/* +hash */
+group by l.l_orderkey as l_orderkey,o.o_orderdate as o_orderdate,o.o_shippriority as o_shippriority
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  ))
+order by revenue desc,o_orderdate
+limit 10
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
new file mode 100644
index 0000000..1e5c50e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp() {
+(
+    select element {'o_orderkey':l.l_orderkey}
+    from  LineItem as l
+    where (l.l_commitdate < l.l_receiptdate)
+)
+};
+select element {'order_priority':o_orderpriority,'count':tpch.count(o)}
+from  Orders as o,
+      tpch.tmp() as t
+where ((o.o_orderkey = t.o_orderkey) and (o.o_orderdate >= '1993-07-01') and (o.o_orderdate < '1993-10-01'))
+group by o.o_orderpriority as o_orderpriority
+order by o_orderpriority
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
new file mode 100644
index 0000000..150e4b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch;
+
+
+select element {'n_name':n_name,'revenue':revenue}
+from  Customer as c,
+      (
+    select element {'n_name':l1.n_name,'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'s_nationkey':l1.s_nationkey,'o_custkey':o.o_custkey}
+    from  Orders as o,
+          (
+        select element {'n_name':s1.n_name,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_orderkey':l.l_orderkey,'s_nationkey':s1.s_nationkey}
+        from  LineItem as l,
+              (
+            select element {'n_name':n1.n_name,'s_suppkey':s.s_suppkey,'s_nationkey':s.s_nationkey}
+            from  Supplier as s,
+                  (
+                select element {'n_name':n.n_name,'n_nationkey':n.n_nationkey}
+                from  Nation as n,
+                      Region as r
+                where (n.n_regionkey = r.r_regionkey)
+            ) as n1
+            where (s.s_nationkey = n1.n_nationkey)
+        ) as s1
+        where (l.l_suppkey = s1.s_suppkey)
+    ) as l1
+    where ((l1.l_orderkey = o.o_orderkey) and (o.o_orderdate >= '1990-01-01') and (o.o_orderdate < '1995-01-01'))
+) as o1
+where ((c.c_nationkey = o1.s_nationkey) and (c.c_custkey = o1.o_custkey))
+/* +hash */
+group by o1.n_name as n_name
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  o1 as i
+  ))
+order by revenue desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
new file mode 100644
index 0000000..9dee61f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+{'revenue':tpch.sum((
+    select element (l.l_extendedprice * l.l_discount)
+    from  LineItem as l
+    where ((l.l_shipdate >= '1994-01-01') and (l.l_shipdate < '1995-01-01') and (l.l_discount >= 0.05) and (l.l_discount <= 0.07) and (l.l_quantity < 24))
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
new file mode 100644
index 0000000..74d3b5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.query.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 tpch;
+
+
+declare function q7_volume_shipping_tmp() {
+(
+    select element {'supp_nation':n1.n_name,'cust_nation':n2.n_name,'s_nationkey':n1.n_nationkey,'c_nationkey':n2.n_nationkey}
+    from  Nation as n1,
+          Nation as n2
+    where ((n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY'))
+)
+};
+select element {'supp_nation':supp_nation,'cust_nation':cust_nation,'l_year':l_year,'revenue':revenue}
+from  (
+    select element {'l_shipdate':loc.l_shipdate,'l_extendedprice':loc.l_extendedprice,'l_discount':loc.l_discount,'c_nationkey':loc.c_nationkey,'s_nationkey':s.s_nationkey}
+    from  (
+        select element {'l_shipdate':lo.l_shipdate,'l_extendedprice':lo.l_extendedprice,'l_discount':lo.l_discount,'l_suppkey':lo.l_suppkey,'c_nationkey':c.c_nationkey}
+        from  (
+            select element {'l_shipdate':l.l_shipdate,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_suppkey':l.l_suppkey,'o_custkey':o.o_custkey}
+            from  LineItem as l,
+                  Orders as o
+            where ((o.o_orderkey = l.l_orderkey) and (l.l_shipdate >= '1992-01-01') and (l.l_shipdate <= '1996-12-31'))
+        ) as lo,
+              Customer as c
+        where (c.c_custkey = lo.o_custkey)
+    ) as loc,
+          Supplier as s
+    where (s.s_suppkey = loc.l_suppkey)
+) as locs,
+      tpch.q7_volume_shipping_tmp() as t
+with  l_year0 as tpch."get-year"(locs.l_shipdate)
+where ((locs.c_nationkey = t.c_nationkey) and (locs.s_nationkey = t.s_nationkey))
+group by t.supp_nation as supp_nation,t.cust_nation as cust_nation,l_year0 as l_year
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  locs as i
+  ))
+order by supp_nation,cust_nation,l_year
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
new file mode 100644
index 0000000..77d3881
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.query.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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 tpch;
+
+
+select element {'year':year,'mkt_share':(tpch.sum((
+          select element tpch."switch-case"((i.s_name = 'BRAZIL'),true,i.revenue,false,0.0)
+          from  t as i
+      )) / tpch.sum((
+          select element i.revenue
+          from  t as i
+      )))}
+from  (
+    select element {'year':o_year,'revenue':(slnrcop.l_extendedprice * (1 - slnrcop.l_discount)),'s_name':n2.n_name}
+    from  (
+        select element {'o_orderdate':lnrcop.o_orderdate,'l_discount':lnrcop.l_discount,'l_extendedprice':lnrcop.l_extendedprice,'l_suppkey':lnrcop.l_suppkey,'s_nationkey':s.s_nationkey}
+        from  Supplier as s,
+              (
+            select element {'o_orderdate':lnrco.o_orderdate,'l_discount':lnrco.l_discount,'l_extendedprice':lnrco.l_extendedprice,'l_suppkey':lnrco.l_suppkey}
+            from  (
+                select element {'o_orderdate':nrco.o_orderdate,'l_partkey':l.l_partkey,'l_discount':l.l_discount,'l_extendedprice':l.l_extendedprice,'l_suppkey':l.l_suppkey}
+                from  LineItem as l,
+                      (
+                    select element {'o_orderdate':o.o_orderdate,'o_orderkey':o.o_orderkey}
+                    from  Orders as o,
+                          (
+                        select element {'c_custkey':c.c_custkey}
+                        from  Customer as c,
+                              (
+                            select element {'n_nationkey':n1.n_nationkey}
+                            from  Nation as n1,
+                                  Region as r1
+                            where ((n1.n_regionkey = r1.r_regionkey) and (r1.r_name = 'AMERICA'))
+                        ) as nr
+                        where (c.c_nationkey = nr.n_nationkey)
+                    ) as nrc
+                    where (nrc.c_custkey = o.o_custkey)
+                ) as nrco
+                where ((l.l_orderkey = nrco.o_orderkey) and (nrco.o_orderdate >= '1995-01-01') and (nrco.o_orderdate < '1996-12-31'))
+            ) as lnrco,
+                  Part as p
+            where ((p.p_partkey = lnrco.l_partkey) and (p.p_type = 'ECONOMY ANODIZED STEEL'))
+        ) as lnrcop
+        where (s.s_suppkey = lnrcop.l_suppkey)
+    ) as slnrcop,
+          Nation as n2
+    with  o_year as tpch."get-year"(slnrcop.o_orderdate)
+    where (slnrcop.s_nationkey = n2.n_nationkey)
+) as t
+group by t.year as year
+order by year
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
new file mode 100644
index 0000000..f7e2e8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.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 tpch;
+
+
+select element {'nation':nation,'o_year':o_year,'sum_profit':tpch.sum((
+        select element pr.amount
+        from  profit as pr
+    ))}
+from  (
+    select element {'nation':l3.n_name,'o_year':o_year,'amount':amount}
+    from  Orders as o,
+          (
+        select element {'l_extendedprice':l2.l_extendedprice,'l_discount':l2.l_discount,'l_quantity':l2.l_quantity,'l_orderkey':l2.l_orderkey,'n_name':l2.n_name,'ps_supplycost':l2.ps_supplycost}
+        from  Part as p,
+              (
+            select element {'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'l_quantity':l1.l_quantity,'l_partkey':l1.l_partkey,'l_orderkey':l1.l_orderkey,'n_name':l1.n_name,'ps_supplycost':ps.ps_supplycost}
+            from  Partsupp as ps,
+                  (
+                select element {'l_suppkey':l.l_suppkey,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_quantity':l.l_quantity,'l_partkey':l.l_partkey,'l_orderkey':l.l_orderkey,'n_name':s1.n_name}
+                from  (
+                    select element {'s_suppkey':s.s_suppkey,'n_name':n.n_name}
+                    from  Supplier as s,
+                          Nation as n
+                    where (n.n_nationkey = s.s_nationkey)
+                ) as s1,
+                      LineItem as l
+                where (s1.s_suppkey = l.l_suppkey)
+            ) as l1
+            where ((ps.ps_suppkey = l1.l_suppkey) and (ps.ps_partkey = l1.l_partkey))
+        ) as l2
+        where (tpch.contains(p.p_name,'green') and (p.p_partkey = l2.l_partkey))
+    ) as l3
+    with  amount as ((l3.l_extendedprice * (1 - l3.l_discount)) - (l3.ps_supplycost * l3.l_quantity)),
+          o_year as tpch."get-year"(o.o_orderdate)
+    where (o.o_orderkey = l3.l_orderkey)
+) as profit
+group by profit.nation as nation,profit.o_year as o_year
+order by nation,o_year desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.1.ddl.sqlpp
new file mode 100644
index 0000000..aede39f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.2.update.sqlpp
new file mode 100644
index 0000000..e5f3d28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
new file mode 100644
index 0000000..f75030c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 tpch;
+
+
+select element {'c_custkey':c_custkey,'c_name':c_name,'revenue':revenue,'c_acctbal':c_acctbal,'n_name':n_name,'c_address':c_address,'c_phone':c_phone,'c_comment':c_comment}
+from  (
+    select element {'c_custkey':ocn.c_custkey,'c_name':ocn.c_name,'c_acctbal':ocn.c_acctbal,'n_name':ocn.n_name,'c_address':ocn.c_address,'c_phone':ocn.c_phone,'c_comment':ocn.c_comment,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount}
+    from  LineItem as l,
+          (
+        select element {'c_custkey':c.c_custkey,'c_name':c.c_name,'c_acctbal':c.c_acctbal,'n_name':n.n_name,'c_address':c.c_address,'c_phone':c.c_phone,'c_comment':c.c_comment,'o_orderkey':o.o_orderkey}
+        from  Orders as o,
+              Customer as c,
+              Nation as n
+        where (((c.c_custkey = o.o_custkey) and (o.o_orderdate >= '1993-10-01') and (o.o_orderdate < '1994-01-01')) and (c.c_nationkey = n.n_nationkey))
+    ) as ocn
+    where ((l.l_orderkey = ocn.o_orderkey) and (l.l_selectflag = 'R'))
+) as locn
+group by locn.c_custkey as c_custkey,locn.c_name as c_name,locn.c_acctbal as c_acctbal,locn.c_phone as c_phone,locn.n_name as n_name,locn.c_address as c_address,locn.c_comment as c_comment
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  locn as i
+  ))
+order by revenue desc
+limit 20
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
new file mode 100644
index 0000000..f75030c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 tpch;
+
+
+select element {'c_custkey':c_custkey,'c_name':c_name,'revenue':revenue,'c_acctbal':c_acctbal,'n_name':n_name,'c_address':c_address,'c_phone':c_phone,'c_comment':c_comment}
+from  (
+    select element {'c_custkey':ocn.c_custkey,'c_name':ocn.c_name,'c_acctbal':ocn.c_acctbal,'n_name':ocn.n_name,'c_address':ocn.c_address,'c_phone':ocn.c_phone,'c_comment':ocn.c_comment,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount}
+    from  LineItem as l,
+          (
+        select element {'c_custkey':c.c_custkey,'c_name':c.c_name,'c_acctbal':c.c_acctbal,'n_name':n.n_name,'c_address':c.c_address,'c_phone':c.c_phone,'c_comment':c.c_comment,'o_orderkey':o.o_orderkey}
+        from  Orders as o,
+              Customer as c,
+              Nation as n
+        where (((c.c_custkey = o.o_custkey) and (o.o_orderdate >= '1993-10-01') and (o.o_orderdate < '1994-01-01')) and (c.c_nationkey = n.n_nationkey))
+    ) as ocn
+    where ((l.l_orderkey = ocn.o_orderkey) and (l.l_selectflag = 'R'))
+) as locn
+group by locn.c_custkey as c_custkey,locn.c_name as c_name,locn.c_acctbal as c_acctbal,locn.c_phone as c_phone,locn.n_name as n_name,locn.c_address as c_address,locn.c_comment as c_comment
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  locn as i
+  ))
+order by revenue desc
+limit 20
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.sqlpp
new file mode 100644
index 0000000..ea3bd5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.query.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.
+ */
+
+use tpch;
+
+
+with  sum as tpch.sum((
+      select element (ps.ps_supplycost * ps.ps_availqty)
+      from  Partsupp as ps,
+            (
+          select element {'s_suppkey':s.s_suppkey}
+          from  Supplier as s,
+                Nation as n
+          where (s.s_nationkey = n.n_nationkey)
+      ) as sn
+      where (ps.ps_suppkey = sn.s_suppkey)
+  ))
+select element {'partkey':t1.ps_partkey,'part_value':t1.part_value}
+from  (
+    select element {'ps_partkey':ps_partkey,'part_value':tpch.sum((
+            select element (i.ps_supplycost * i.ps_availqty)
+            from  ps as i
+        ))}
+    from  Partsupp as ps,
+          (
+        select element {'s_suppkey':s.s_suppkey}
+        from  Supplier as s,
+              Nation as n
+        where (s.s_nationkey = n.n_nationkey)
+    ) as sn
+    where (ps.ps_suppkey = sn.s_suppkey)
+    group by ps.ps_partkey as ps_partkey
+) as t1
+where (t1.part_value > (sum * 0.00001))
+order by t1.part_value desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
new file mode 100644
index 0000000..61b685e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 tpch;
+
+
+select element {'l_shipmode':l_shipmode,'high_line_count':tpch.sum((
+        select element tpch."switch-case"(((i.o_orderpriority = '1-URGENT') or (i.o_orderpriority = '2-HIGH')),true,1,false,0)
+        from  o as i
+    )),'low_line_count':tpch.sum((
+        select element tpch."switch-case"(((i.o_orderpriority = '1-URGENT') or (i.o_orderpriority = '2-HIGH')),true,0,false,1)
+        from  o as i
+    ))}
+from  LineItem as l,
+      Orders as o
+where ((o.o_orderkey = l.l_orderkey) and (l.l_commitdate < l.l_receiptdate) and (l.l_shipdate < l.l_commitdate) and (l.l_receiptdate >= '1994-01-01') and (l.l_receiptdate < '1995-01-01') and ((l.l_shipmode = 'MAIL') or (l.l_shipmode = 'SHIP')))
+group by l.l_shipmode as l_shipmode
+order by l_shipmode
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
new file mode 100644
index 0000000..afa7c9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 tpch;
+
+
+set "import-private-functions" "true";
+
+select element {'c_count':c_count,'custdist':custdist}
+from  (
+    select element {'c_custkey':c_custkey,'c_count':tpch.sum((
+            select element i.o_orderkey_count
+            from  co as i
+        ))}
+    from  (
+        select element {'c_custkey':c.c_custkey,'o_orderkey_count':tpch.count((
+                select element o.o_orderkey
+                from  Orders as o
+                where ((c.c_custkey = o.o_custkey) and tpch.not(tpch.like(o.o_comment,'%special%requests%')))
+            ))}
+        from  Customer as c
+    ) as co
+    group by co.c_custkey as c_custkey
+) as gco
+group by gco.c_count as c_count
+with  custdist as tpch.count(gco)
+order by custdist desc,c_count desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
new file mode 100644
index 0000000..559dfc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.query.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.
+ */
+
+use tpch;
+
+
+select element (100.0 * tpch.sum((
+      select element tpch."switch-case"(tpch.like(i.p_type,'PROMO%'),true,(i.l_extendedprice * (1 - i.l_discount)),false,0.0)
+      from  l as i
+  )) / tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  )))
+from  LineItem as l,
+      Part as p
+where ((l.l_partkey = p.p_partkey) and (l.l_shipdate >= '1995-09-01') and (l.l_shipdate < '1995-10-01'))
+group by 1 as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
new file mode 100644
index 0000000..e21104b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 tpch;
+
+
+declare function revenue() {
+(
+    select element {'supplier_no':l_suppkey,'total_revenue':tpch.sum((
+            select element (i.l_extendedprice * (1 - i.l_discount))
+            from  l as i
+        ))}
+    from  LineItem as l
+    where ((l.l_shipdate >= '1996-01-01') and (l.l_shipdate < '1996-04-01'))
+    group by l.l_suppkey as l_suppkey
+)
+};
+with  m as tpch.max((
+      select element r2.total_revenue
+      from  tpch.revenue() as r2
+  ))
+select element {'s_suppkey':s.s_suppkey,'s_name':s.s_name,'s_address':s.s_address,'s_phone':s.s_phone,'total_revenue':r.total_revenue}
+from  Supplier as s,
+      tpch.revenue() as r
+where ((s.s_suppkey = r.supplier_no) and (r.total_revenue < (m + 0.000000001)) and (r.total_revenue > (m - 0.000000001)))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
new file mode 100644
index 0000000..cc4d01a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp() {
+(
+    select element {'p_brand':psp.p_brand,'p_type':psp.p_type,'p_size':psp.p_size,'ps_suppkey':psp.ps_suppkey}
+    from  (
+        select element {'p_brand':p.p_brand,'p_type':p.p_type,'p_size':p.p_size,'ps_suppkey':ps.ps_suppkey}
+        from  Partsupp as ps,
+              Part as p
+        where ((p.p_partkey = ps.ps_partkey) and (p.p_brand != 'Brand#45') and tpch.not(tpch.like(p.p_type,'MEDIUM POLISHED%')))
+    ) as psp,
+          Supplier as s
+    where ((psp.ps_suppkey = s.s_suppkey) and tpch.not(tpch.like(s.s_comment,'%Customer%Complaints%')))
+)
+};
+select element {'p_brand':p_brand,'p_type':p_type,'p_size':p_size,'supplier_cnt':supplier_cnt}
+from  (
+    select element {'p_brand':p_brand1,'p_type':p_type1,'p_size':p_size1,'ps_suppkey':ps_suppkey1}
+    from  tpch.tmp() as t
+    where ((t.p_size = 49) or (t.p_size = 14) or (t.p_size = 23) or (t.p_size = 45) or (t.p_size = 19) or (t.p_size = 3) or (t.p_size = 36) or (t.p_size = 9))
+    group by t.p_brand as p_brand1,t.p_type as p_type1,t.p_size as p_size1,t.ps_suppkey as ps_suppkey1
+) as t2
+group by t2.p_brand as p_brand,t2.p_type as p_type,t2.p_size as p_size
+with  supplier_cnt as tpch.count((
+      select element i.ps_suppkey
+      from  t2 as i
+  ))
+order by supplier_cnt desc,p_brand,p_type,p_size
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
new file mode 100644
index 0000000..ada4f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.query.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 tpch;
+
+
+select element {'t_partkey':l_partkey,'t_count':tpch.count(l),'t_avg_quantity':(0.2 * tpch.avg((
+          select element i.l_quantity
+          from  l as i
+      ))),'t_max_suppkey':tpch.max((
+        select element i.l_suppkey
+        from  l as i
+    )),'t_max_linenumber':tpch.max((
+        select element i.l_linenumber
+        from  l as i
+    )),'t_avg_extendedprice':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'t_avg_discount':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'t_avg_tax':tpch.avg((
+        select element i.l_tax
+        from  l as i
+    )),'t_max_shipdate':tpch.max((
+        select element i.l_shipdate
+        from  l as i
+    )),'t_min_commitdate':tpch.min((
+        select element i.l_commitdate
+        from  l as i
+    )),'t_min_receiptdate':tpch.min((
+        select element i.l_receiptdate
+        from  l as i
+    )),'t_max_comment':tpch.max((
+        select element i.l_comment
+        from  l as i
+    ))}
+from  LineItem as l
+group by l.l_partkey as l_partkey
+order by l_partkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
new file mode 100644
index 0000000..2a24bd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.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.
+ */
+
+use tpch;
+
+
+declare function tmp() {
+(
+    select element {'t_partkey':l_partkey,'t_avg_quantity':(0.2 * tpch.avg((
+              select element i.l_quantity
+              from  l as i
+          )))}
+    from  LineItem as l
+    group by l.l_partkey as l_partkey
+)
+};
+select element (tpch.sum((
+      select element l.l_extendedprice
+      from  LineItem as l,
+            Part as p,
+            tpch.tmp() as t
+      where (((p.p_partkey = l.l_partkey) and (p.p_container = 'MED BOX')) and ((l.l_partkey = t.t_partkey) and (l.l_quantity < t.t_avg_quantity)))
+  )) / 7.0);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
new file mode 100644
index 0000000..15081ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 tpch;
+
+
+select element {'c_name':c_name,'c_custkey':c_custkey,'o_orderkey':o_orderkey,'o_orderdate':o_orderdate,'o_totalprice':o_totalprice,'sum_quantity':tpch.sum((
+        select element j.l_quantity
+        from  l as j
+    ))}
+from  Customer as c,
+      Orders as o,
+      (
+    select element {'l_orderkey':l_orderkey,'t_sum_quantity':tpch.sum((
+            select element i.l_quantity
+            from  l as i
+        ))}
+    from  LineItem as l
+    group by l.l_orderkey as l_orderkey
+) as t,
+      LineItem as l
+where ((c.c_custkey = o.o_custkey) and ((o.o_orderkey = t.l_orderkey) and (t.t_sum_quantity > 30)) and (l.l_orderkey = o.o_orderkey))
+group by c.c_name as c_name,c.c_custkey as c_custkey,o.o_orderkey as o_orderkey,o.o_orderdate as o_orderdate,o.o_totalprice as o_totalprice
+order by o_totalprice desc,o_orderdate
+limit 100
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
new file mode 100644
index 0000000..7065f87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use tpch;
+
+
+set "import-private-functions" "true";
+
+select element tpch.sum((
+    select element (l.l_extendedprice * (1 - l.l_discount))
+    from  LineItem as l,
+          Part as p
+    where ((p.p_partkey = l.l_partkey) and (((p.p_brand = 'Brand#12') and tpch."reg-exp"(p.p_container,'SM CASE||SM BOX||SM PACK||SM PKG') and (l.l_quantity >= 1) and (l.l_quantity <= 11) and (p.p_size >= 1) and (p.p_size <= 5) and tpch."reg-exp"(l.l_shipmode,'AIR||AIR REG') and (l.l_shipinstruct = 'DELIVER IN PERSON')) or ((p.p_brand = 'Brand#23') and tpch."reg-exp"(p.p_container,'MED BAG||MED BOX||MED PKG||MED PACK') and (l.l_quantity >= 10) and (l.l_quantity <= 20) and (p.p_size >= 1) and (p.p_size <= 10) and tpch."reg-exp"(l.l_shipmode,'AIR||AIR REG') and (l.l_shipinstruct = 'DELIVER IN PERSON')) or ((p.p_brand = 'Brand#34') and tpch."reg-exp"(p.p_container,'LG CASE||LG BOX||LG PACK||LG PKG') and (l.l_quantity >= 20) and (l.l_quantity <= 30) and (p.p_size >= 1) and (p.p_size <= 15) and tpch."reg-exp"(l.l_shipmode,'AIR||AIR REG') and (l.l_shipinstruct = 'DELIVER IN PERSON'))))
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
new file mode 100644
index 0000000..31810e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.query.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.
+ */
+
+use tpch;
+
+
+select element {'s_name':t4.s_name,'s_address':t4.s_address}
+from  (
+    select element {'ps_suppkey':pst1.ps_suppkey}
+    from  (
+        select element {'l_partkey':l_partkey,'l_suppkey':l_suppkey,'sum_quantity':(0.5 * tpch.sum((
+                  select element i.l_quantity
+                  from  l as i
+              )))}
+        from  LineItem as l
+        group by l.l_partkey as l_partkey,l.l_suppkey as l_suppkey
+    ) as t2,
+          (
+        select element {'ps_suppkey':ps.ps_suppkey,'ps_partkey':ps.ps_partkey,'ps_availqty':ps.ps_availqty}
+        from  Partsupp as ps,
+              (
+            select element {'p_partkey':p.p_partkey}
+            from  Part as p
+        ) as t1
+        where (ps.ps_partkey = t1.p_partkey)
+    ) as pst1
+    where ((pst1.ps_partkey = t2.l_partkey) and (pst1.ps_suppkey = t2.l_suppkey) and (pst1.ps_availqty > t2.sum_quantity))
+) as t3,
+      (
+    select element {'s_name':s.s_name,'s_address':s.s_address,'s_suppkey':s.s_suppkey}
+    from  Nation as n,
+          Supplier as s
+    where (s.s_nationkey = n.n_nationkey)
+) as t4
+where (t3.ps_suppkey = t4.s_suppkey)
+order by t4.s_name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
new file mode 100644
index 0000000..5382019
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp1() {
+(
+    select element {'l_orderkey':l_orderkey,'count_suppkey':tpch.count((
+            select element i.l_suppkey
+            from  l2 as i
+        )),'max_suppkey':tpch.max((
+            select element i.l_suppkey
+            from  l2 as i
+        ))}
+    from  (
+        select element {'l_orderkey':l_orderkey1,'l_suppkey':l_suppkey1}
+        from  LineItem as l
+        group by l.l_orderkey as l_orderkey1,l.l_suppkey as l_suppkey1
+    ) as l2
+    group by l2.l_orderkey as l_orderkey
+)
+};
+declare function tmp2() {
+(
+    select element {'l_orderkey':l_orderkey,'count_suppkey':tpch.count((
+            select element i.l_suppkey
+            from  l2 as i
+        )),'max_suppkey':tpch.max((
+            select element i.l_suppkey
+            from  l2 as i
+        ))}
+    from  (
+        select element {'l_orderkey':l_orderkey1,'l_suppkey':l_suppkey1}
+        from  LineItem as l
+        where (l.l_receiptdate > l.l_commitdate)
+        group by l.l_orderkey as l_orderkey1,l.l_suppkey as l_suppkey1
+    ) as l2
+    group by l2.l_orderkey as l_orderkey
+)
+};
+select element {'s_name':s_name,'numwait':numwait}
+from  (
+    select element {'s_name':t3.s_name,'l_suppkey':t3.l_suppkey,'l_orderkey':t2.l_orderkey,'count_suppkey':t2.count_suppkey,'max_suppkey':t2.max_suppkey}
+    from  (
+        select element {'s_name':ns.s_name,'l_orderkey':t1.l_orderkey,'l_suppkey':l.l_suppkey}
+        from  LineItem as l,
+              (
+            select element {'s_name':s.s_name,'s_suppkey':s.s_suppkey}
+            from  Nation as n,
+                  Supplier as s
+            where (s.s_nationkey = n.n_nationkey)
+        ) as ns,
+              Orders as o,
+              tpch.tmp1() as t1
+        where (((ns.s_suppkey = l.l_suppkey) and (l.l_receiptdate > l.l_commitdate)) and (o.o_orderkey = l.l_orderkey) and (l.l_orderkey = t1.l_orderkey))
+    ) as t3,
+          tpch.tmp2() as t2
+    where ((t2.count_suppkey >= 0) and (t3.l_orderkey = t2.l_orderkey))
+) as t4
+group by t4.s_name as s_name
+with  numwait as tpch.count(t4)
+order by numwait desc,s_name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ddl.sqlpp
new file mode 100644
index 0000000..26c325d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
new file mode 100644
index 0000000..6136008
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 tpch;
+
+
+declare function q22_customer_tmp() {
+(
+    select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':tpch.substring(c.c_phone,1,2)}
+    from  Customer as c
+)
+};
+with  avg as tpch.avg((
+      select element c.c_acctbal
+      from  Customer as c
+      where (c.c_acctbal > 0.0)
+  ))
+select element {'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.sum((
+        select element i.c_acctbal
+        from  ct as i
+    ))}
+from  tpch.q22_customer_tmp() as ct
+where (ct.c_acctbal > avg)
+group by ct.cntrycode as cntrycode
+order by cntrycode
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.1.ddl.sqlpp
new file mode 100644
index 0000000..f1845bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix from issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.2.update.sqlpp
new file mode 100644
index 0000000..8cfafdc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix from issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.sqlpp
new file mode 100644
index 0000000..44852ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix from issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+use tpch;
+
+
+select element {'l_linenumber':l_linenumber,'count_order':tpch.count(l)}
+from  LineItem as l
+group by l.l_linenumber as l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.1.ddl.sqlpp
new file mode 100644
index 0000000..db25f47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.1.ddl.sqlpp
@@ -0,0 +1,140 @@
+/*
+ * 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  : This test case is to verify the fix from issue638
+ * https://code.google.com/p/asterixdb/issues/detail?id=638
+ * Expected Res : SUCCESS
+ * Date         : 24th Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_selectflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create external  table LineItem(LineItemType) using "localfs"(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Orders(OrderType) using "localfs"(("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Supplier(SupplierType) using "localfs"(("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Region(RegionType) using "localfs"(("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Nation(NationType) using "localfs"(("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Part(PartType) using "localfs"(("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Partsupp(PartSuppType) using "localfs"(("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Customer(CustomerType) using "localfs"(("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.2.update.sqlpp
new file mode 100644
index 0000000..f7b35af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix from issue638
+ * https://code.google.com/p/asterixdb/issues/detail?id=638
+ * Expected Res : SUCCESS
+ * Date         : 24th Oct. 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
new file mode 100644
index 0000000..d2e8a7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.query.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : This test case is to verify the fix from issue638
+ * https://code.google.com/p/asterixdb/issues/detail?id=638
+ * Expected Res : SUCCESS
+ * Date         : 24th Oct. 2014
+ */
+
+use tpch;
+
+
+select element {'nation':nation,'o_year':o_year,'sum_profit':tpch.sum((
+        select element pr.amount
+        from  profit as pr
+    ))}
+from  (
+    select element {'nation':l3.n_name,'o_year':o_year,'amount':amount}
+    from  Orders as o,
+          (
+        select element {'l_extendedprice':l2.l_extendedprice,'l_discount':l2.l_discount,'l_quantity':l2.l_quantity,'l_orderkey':l2.l_orderkey,'n_name':l2.n_name,'ps_supplycost':l2.ps_supplycost}
+        from  Part as p,
+              (
+            select element {'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'l_quantity':l1.l_quantity,'l_partkey':l1.l_partkey,'l_orderkey':l1.l_orderkey,'n_name':l1.n_name,'ps_supplycost':ps.ps_supplycost}
+            from  Partsupp as ps,
+                  (
+                select element {'l_suppkey':l.l_suppkey,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_quantity':l.l_quantity,'l_partkey':l.l_partkey,'l_orderkey':l.l_orderkey,'n_name':s1.n_name}
+                from  (
+                    select element {'s_suppkey':s.s_suppkey,'n_name':n.n_name}
+                    from  Supplier as s,
+                          Nation as n
+                    where (n.n_nationkey = s.s_nationkey)
+                ) as s1,
+                      LineItem as l
+                where (s1.s_suppkey = l.l_suppkey)
+            ) as l1
+            where ((ps.ps_suppkey = l1.l_suppkey) and (ps.ps_partkey = l1.l_partkey))
+        ) as l2
+        where (tpch.contains(p.p_name,'green') and (p.p_partkey = l2.l_partkey))
+    ) as l3
+    with  amount as ((l3.l_extendedprice * (1 - l3.l_discount)) - (l3.ps_supplycost * l3.l_quantity)),
+          o_year as tpch."get-year"(o.o_orderdate)
+    where (o.o_orderkey = l3.l_orderkey)
+) as profit
+group by profit.nation as nation,profit.o_year as o_year
+order by nation,o_year desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.1.ddl.sqlpp
new file mode 100644
index 0000000..2ad97d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix from issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.2.update.sqlpp
new file mode 100644
index 0000000..e345e90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix from issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
new file mode 100644
index 0000000..341d824
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.query.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : This test case is to verify the fix from issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+with  t as (
+      select element {'n_nationkey':nation.n_nationkey,'n_name':nation.n_name}
+      from  Nation as nation,
+            SelectedNation as sn
+      where (nation.n_nationkey = sn.n_nationkey)
+  ),
+      X as (
+      select element {'nation_key':nation_key,'order_date':orderdate,'sum_price':sum}
+      from  t as n,
+            Customer as customer,
+            Orders as orders
+      where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = n.n_nationkey))
+      group by orders.o_orderdate as orderdate,n.n_nationkey as nation_key
+      with  sum as tpch.sum((
+            select element o.o_totalprice
+            from  orders as o
+        ))
+  )
+select element {'nation_key':nation_key,'sum_price':(
+        select element {'orderdate':y.order_date,'sum_price':y.sum_price}
+        from  x as y
+        order by y.sum_price desc
+        limit 3
+    )}
+from  X as x
+group by x.nation_key as nation_key
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.1.ddl.sqlpp
new file mode 100644
index 0000000..2ad97d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix from issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.2.update.sqlpp
new file mode 100644
index 0000000..e345e90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix from issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.sqlpp
new file mode 100644
index 0000000..0f31629
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix from issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+select element {'nation_key':nation_key,'sum_price':(
+        select element {'orderdate':od,'sum_price':sum}
+        from  x as i
+        group by i.order_date as od
+        with  sum as tpch.sum((
+              select element s.sum_price
+              from  i as s
+          ))
+        order by sum desc
+        limit 3
+    )}
+from  (
+    select element {'nation_key':nation_key,'order_date':orderdate,'sum_price':tpch.sum((
+            select element o.o_totalprice
+            from  orders as o
+        ))}
+    from  Nation as n,
+          Customer as customer,
+          Orders as orders
+    where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = n.n_nationkey))
+    group by orders.o_orderdate as orderdate,n.n_nationkey as nation_key
+) as x
+group by x.nation_key as nation_key
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.1.ddl.sqlpp
new file mode 100644
index 0000000..47ee79b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix from issue786
+ * https://code.google.com/p/asterixdb/issues/detail?id=786
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.2.update.sqlpp
new file mode 100644
index 0000000..3ac6fc7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix from issue786
+ * https://code.google.com/p/asterixdb/issues/detail?id=786
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct. 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
new file mode 100644
index 0000000..c35853c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.query.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : This test case is to verify the fix from issue786
+ * https://code.google.com/p/asterixdb/issues/detail?id=786
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct. 2014
+ */
+
+use tpch;
+
+
+select element {'nation_key':nation.n_nationkey,'name':nation.n_name,'aggregates':(
+        select element {'order_date':orderdate,'sum_price':sum}
+        from  Orders as orders,
+              Customer as customer
+        where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = nation.n_nationkey))
+        group by orders.o_orderdate as orderdate
+        with  sum as tpch.sum((
+              select element o.o_totalprice
+              from  orders as o
+          ))
+        order by sum desc
+        limit 3
+    )}
+from  Nation as nation,
+      SelectedNation as sn
+where (nation.n_nationkey = sn.sn_nationkey)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.1.ddl.sqlpp
new file mode 100644
index 0000000..c5fcd3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.2.update.sqlpp
new file mode 100644
index 0000000..2c89045
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.2.update.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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.3.query.sqlpp
new file mode 100644
index 0000000..1bf1990
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/distinct_by/distinct_by.3.query.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.
+ */
+
+use tpch;
+
+
+select element {'l_returnflag':l.l_returnflag,'l_linestatus':l.l_linestatus,'l_shipmode':l.l_shipmode}
+from  LineItem as l
+order by l.l_returnflag,l.l_linestatus,l.l_shipmode
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.1.ddl.sqlpp
new file mode 100644
index 0000000..581b684
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Regions_group_no_agg(RegionType) primary key r_regionkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.2.update.sqlpp
new file mode 100644
index 0000000..b97382c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.2.update.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 tpch;
+
+
+load  table Regions_group_no_agg using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.3.query.sqlpp
new file mode 100644
index 0000000..be7b8ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/group_no_agg/group_no_agg.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+select element name
+from  Regions_group_no_agg as r
+group by r.r_name as name
+order by name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.1.ddl.sqlpp
new file mode 100644
index 0000000..3b070de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix for issue782
+ * https://code.google.com/p/asterixdb/issues/detail?id=782
+ * Expected Res : SUCCESS
+ * Date         : 2nd Jun 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.2.update.sqlpp
new file mode 100644
index 0000000..7aadfd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix for issue782
+ * https://code.google.com/p/asterixdb/issues/detail?id=782
+ * Expected Res : SUCCESS
+ * Date         : 2nd Jun 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.3.query.sqlpp
new file mode 100644
index 0000000..ade2173
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/nest_aggregate/nest_aggregate.3.query.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : This test case is to verify the fix for issue782
+ * https://code.google.com/p/asterixdb/issues/detail?id=782
+ * Expected Res : SUCCESS
+ * Date         : 2nd Jun 2014
+ */
+
+use tpch;
+
+
+select element {'nation_key':nation.n_nationkey,'name':nation.n_name,'aggregates':(
+        select element {'order_date':orderdate,'sum_price':sum}
+        from  Orders as orders,
+              Customer as customer
+        where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = nation.n_nationkey))
+        group by orders.o_orderdate as orderdate
+        with  sum as tpch.sum((
+              select element o.o_totalprice
+              from  orders as o
+          ))
+        order by sum
+        limit 3
+    )}
+from  Nation as nation,
+      SelectedNation as sn
+where (nation.n_nationkey = sn.n_nationkey)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..8649a3b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ddl.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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.sqlpp
new file mode 100644
index 0000000..2c89045
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.update.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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.sqlpp
new file mode 100644
index 0000000..94b313f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.query.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.
+ */
+
+use tpch;
+
+
+set "import-private-functions" "true";
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'sum_qty':tpch.sum((
+        select element i.l_quantity
+        from  l as i
+    )),'sum_base_price':tpch.sum((
+        select element i.l_extendedprice
+        from  l as i
+    )),'sum_disc_price':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount))
+        from  l as i
+    )),'sum_charge':tpch.sum((
+        select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+        from  l as i
+    )),'ave_qty':tpch.avg((
+        select element i.l_quantity
+        from  l as i
+    )),'ave_price':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'ave_disc':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'count_order':tpch.count(l)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
new file mode 100644
index 0000000..a55c74d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.query.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp1() {
+(
+    select element {'s_acctbal':pssrn.s_acctbal,'s_name':pssrn.s_name,'n_name':pssrn.n_name,'p_partkey':p.p_partkey,'ps_supplycost':pssrn.ps_supplycost,'p_mfgr':p.p_mfgr,'s_address':pssrn.s_address,'s_phone':pssrn.s_phone,'s_comment':pssrn.s_comment}
+    from  Part as p,
+          (
+        select element {'n_name':srn.n_name,'p_partkey':ps.ps_partkey,'ps_supplycost':ps.ps_supplycost,'s_name':srn.s_name,'s_acctbal':srn.s_acctbal,'s_address':srn.s_address,'s_phone':srn.s_phone,'s_comment':srn.s_comment}
+        from  Partsupp as ps,
+              (
+            select element {'s_suppkey':s.s_suppkey,'n_name':rn.n_name,'s_name':s.s_name,'s_acctbal':s.s_acctbal,'s_address':s.s_address,'s_phone':s.s_phone,'s_comment':s.s_comment}
+            from  Supplier as s,
+                  (
+                select element {'n_nationkey':n.n_nationkey,'n_name':n.n_name}
+                from  Region as r,
+                      Nation as n
+                where ((n.n_regionkey = r.r_regionkey) and (r.r_name = 'EUROPE'))
+            ) as rn
+            where (s.s_nationkey = rn.n_nationkey)
+        ) as srn
+        where (srn.s_suppkey = ps.ps_suppkey)
+    ) as pssrn
+    where ((p.p_partkey = pssrn.p_partkey) and tpch.like(p.p_type,'%BRASS'))
+)
+};
+declare function tmp2() {
+(
+    select element {'p_partkey':p_partkey,'ps_min_supplycost':tpch.min((
+            select element i.ps_supplycost
+            from  pssrn as i
+        ))}
+    from  Part as p,
+          (
+        select element {'n_name':srn.n_name,'p_partkey':ps.ps_partkey,'ps_supplycost':ps.ps_supplycost,'s_name':srn.s_name,'s_acctbal':srn.s_acctbal,'s_address':srn.s_address,'s_phone':srn.s_phone,'s_comment':srn.s_comment}
+        from  Partsupp as ps,
+              (
+            select element {'s_suppkey':s.s_suppkey,'n_name':rn.n_name,'s_name':s.s_name,'s_acctbal':s.s_acctbal,'s_address':s.s_address,'s_phone':s.s_phone,'s_comment':s.s_comment}
+            from  Supplier as s,
+                  (
+                select element {'n_nationkey':n.n_nationkey,'n_name':n.n_name}
+                from  Region as r,
+                      Nation as n
+                where ((n.n_regionkey = r.r_regionkey) and (r.r_name = 'EUROPE'))
+            ) as rn
+            where (s.s_nationkey = rn.n_nationkey)
+        ) as srn
+        where (srn.s_suppkey = ps.ps_suppkey)
+    ) as pssrn
+    where ((p.p_partkey = pssrn.p_partkey) and tpch.like(p.p_type,'%BRASS'))
+    /* +hash */
+    group by pssrn.p_partkey as p_partkey
+)
+};
+select element {'s_acctbal':t1.s_acctbal,'s_name':t1.s_name,'n_name':t1.n_name,'p_partkey':t1.p_partkey,'p_mfgr':t1.p_mfgr,'s_address':t1.s_address,'s_phone':t1.s_phone,'s_comment':t1.s_comment}
+from  tpch.tmp2() as t2,
+      tpch.tmp1() as t1
+where ((t1.p_partkey = t2.p_partkey) and (t1.ps_supplycost = t2.ps_min_supplycost))
+order by t1.s_acctbal desc,t1.n_name,t1.s_name,t1.p_partkey
+limit 100
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.sqlpp
new file mode 100644
index 0000000..a9495c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.update.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.
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
new file mode 100644
index 0000000..d30c6d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 tpch;
+
+
+select element {'l_orderkey':l_orderkey,'revenue':revenue,'o_orderdate':o_orderdate,'o_shippriority':o_shippriority}
+from  Customer as c,
+      Orders as o,
+      LineItem as l
+where (((c.c_mktsegment = 'BUILDING') and (c.c_custkey = o.o_custkey)) and ((l.l_orderkey = o.o_orderkey) and (o.o_orderdate < '1995-03-15') and (l.l_shipdate > '1995-03-15')))
+/* +hash */
+group by l.l_orderkey as l_orderkey,o.o_orderdate as o_orderdate,o.o_shippriority as o_shippriority
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  ))
+order by revenue desc,o_orderdate
+limit 10
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.3.query.sqlpp
new file mode 100644
index 0000000..1e5c50e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q04_order_priority/q04_order_priority.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp() {
+(
+    select element {'o_orderkey':l.l_orderkey}
+    from  LineItem as l
+    where (l.l_commitdate < l.l_receiptdate)
+)
+};
+select element {'order_priority':o_orderpriority,'count':tpch.count(o)}
+from  Orders as o,
+      tpch.tmp() as t
+where ((o.o_orderkey = t.o_orderkey) and (o.o_orderdate >= '1993-07-01') and (o.o_orderdate < '1993-10-01'))
+group by o.o_orderpriority as o_orderpriority
+order by o_orderpriority
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
new file mode 100644
index 0000000..150e4b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.query.sqlpp
@@ -0,0 +1,54 @@
+/*
+ * 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 tpch;
+
+
+select element {'n_name':n_name,'revenue':revenue}
+from  Customer as c,
+      (
+    select element {'n_name':l1.n_name,'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'s_nationkey':l1.s_nationkey,'o_custkey':o.o_custkey}
+    from  Orders as o,
+          (
+        select element {'n_name':s1.n_name,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_orderkey':l.l_orderkey,'s_nationkey':s1.s_nationkey}
+        from  LineItem as l,
+              (
+            select element {'n_name':n1.n_name,'s_suppkey':s.s_suppkey,'s_nationkey':s.s_nationkey}
+            from  Supplier as s,
+                  (
+                select element {'n_name':n.n_name,'n_nationkey':n.n_nationkey}
+                from  Nation as n,
+                      Region as r
+                where (n.n_regionkey = r.r_regionkey)
+            ) as n1
+            where (s.s_nationkey = n1.n_nationkey)
+        ) as s1
+        where (l.l_suppkey = s1.s_suppkey)
+    ) as l1
+    where ((l1.l_orderkey = o.o_orderkey) and (o.o_orderdate >= '1990-01-01') and (o.o_orderdate < '1995-01-01'))
+) as o1
+where ((c.c_nationkey = o1.s_nationkey) and (c.c_custkey = o1.o_custkey))
+/* +hash */
+group by o1.n_name as n_name
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  o1 as i
+  ))
+order by revenue desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
new file mode 100644
index 0000000..9dee61f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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 tpch;
+
+
+{'revenue':tpch.sum((
+    select element (l.l_extendedprice * l.l_discount)
+    from  LineItem as l
+    where ((l.l_shipdate >= '1994-01-01') and (l.l_shipdate < '1995-01-01') and (l.l_discount >= 0.05) and (l.l_discount <= 0.07) and (l.l_quantity < 24))
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.query.sqlpp
new file mode 100644
index 0000000..74d3b5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.query.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 tpch;
+
+
+declare function q7_volume_shipping_tmp() {
+(
+    select element {'supp_nation':n1.n_name,'cust_nation':n2.n_name,'s_nationkey':n1.n_nationkey,'c_nationkey':n2.n_nationkey}
+    from  Nation as n1,
+          Nation as n2
+    where ((n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY'))
+)
+};
+select element {'supp_nation':supp_nation,'cust_nation':cust_nation,'l_year':l_year,'revenue':revenue}
+from  (
+    select element {'l_shipdate':loc.l_shipdate,'l_extendedprice':loc.l_extendedprice,'l_discount':loc.l_discount,'c_nationkey':loc.c_nationkey,'s_nationkey':s.s_nationkey}
+    from  (
+        select element {'l_shipdate':lo.l_shipdate,'l_extendedprice':lo.l_extendedprice,'l_discount':lo.l_discount,'l_suppkey':lo.l_suppkey,'c_nationkey':c.c_nationkey}
+        from  (
+            select element {'l_shipdate':l.l_shipdate,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_suppkey':l.l_suppkey,'o_custkey':o.o_custkey}
+            from  LineItem as l,
+                  Orders as o
+            where ((o.o_orderkey = l.l_orderkey) and (l.l_shipdate >= '1992-01-01') and (l.l_shipdate <= '1996-12-31'))
+        ) as lo,
+              Customer as c
+        where (c.c_custkey = lo.o_custkey)
+    ) as loc,
+          Supplier as s
+    where (s.s_suppkey = loc.l_suppkey)
+) as locs,
+      tpch.q7_volume_shipping_tmp() as t
+with  l_year0 as tpch."get-year"(locs.l_shipdate)
+where ((locs.c_nationkey = t.c_nationkey) and (locs.s_nationkey = t.s_nationkey))
+group by t.supp_nation as supp_nation,t.cust_nation as cust_nation,l_year0 as l_year
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  locs as i
+  ))
+order by supp_nation,cust_nation,l_year
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.3.query.sqlpp
new file mode 100644
index 0000000..77d3881
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q08_national_market_share/q08_national_market_share.3.query.sqlpp
@@ -0,0 +1,69 @@
+/*
+ * 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 tpch;
+
+
+select element {'year':year,'mkt_share':(tpch.sum((
+          select element tpch."switch-case"((i.s_name = 'BRAZIL'),true,i.revenue,false,0.0)
+          from  t as i
+      )) / tpch.sum((
+          select element i.revenue
+          from  t as i
+      )))}
+from  (
+    select element {'year':o_year,'revenue':(slnrcop.l_extendedprice * (1 - slnrcop.l_discount)),'s_name':n2.n_name}
+    from  (
+        select element {'o_orderdate':lnrcop.o_orderdate,'l_discount':lnrcop.l_discount,'l_extendedprice':lnrcop.l_extendedprice,'l_suppkey':lnrcop.l_suppkey,'s_nationkey':s.s_nationkey}
+        from  Supplier as s,
+              (
+            select element {'o_orderdate':lnrco.o_orderdate,'l_discount':lnrco.l_discount,'l_extendedprice':lnrco.l_extendedprice,'l_suppkey':lnrco.l_suppkey}
+            from  (
+                select element {'o_orderdate':nrco.o_orderdate,'l_partkey':l.l_partkey,'l_discount':l.l_discount,'l_extendedprice':l.l_extendedprice,'l_suppkey':l.l_suppkey}
+                from  LineItem as l,
+                      (
+                    select element {'o_orderdate':o.o_orderdate,'o_orderkey':o.o_orderkey}
+                    from  Orders as o,
+                          (
+                        select element {'c_custkey':c.c_custkey}
+                        from  Customer as c,
+                              (
+                            select element {'n_nationkey':n1.n_nationkey}
+                            from  Nation as n1,
+                                  Region as r1
+                            where ((n1.n_regionkey = r1.r_regionkey) and (r1.r_name = 'AMERICA'))
+                        ) as nr
+                        where (c.c_nationkey = nr.n_nationkey)
+                    ) as nrc
+                    where (nrc.c_custkey = o.o_custkey)
+                ) as nrco
+                where ((l.l_orderkey = nrco.o_orderkey) and (nrco.o_orderdate >= '1995-01-01') and (nrco.o_orderdate < '1996-12-31'))
+            ) as lnrco,
+                  Part as p
+            where ((p.p_partkey = lnrco.l_partkey) and (p.p_type = 'ECONOMY ANODIZED STEEL'))
+        ) as lnrcop
+        where (s.s_suppkey = lnrcop.l_suppkey)
+    ) as slnrcop,
+          Nation as n2
+    with  o_year as tpch."get-year"(slnrcop.o_orderdate)
+    where (slnrcop.s_nationkey = n2.n_nationkey)
+) as t
+group by t.year as year
+order by year
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.sqlpp
new file mode 100644
index 0000000..f7e2e8f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.query.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 tpch;
+
+
+select element {'nation':nation,'o_year':o_year,'sum_profit':tpch.sum((
+        select element pr.amount
+        from  profit as pr
+    ))}
+from  (
+    select element {'nation':l3.n_name,'o_year':o_year,'amount':amount}
+    from  Orders as o,
+          (
+        select element {'l_extendedprice':l2.l_extendedprice,'l_discount':l2.l_discount,'l_quantity':l2.l_quantity,'l_orderkey':l2.l_orderkey,'n_name':l2.n_name,'ps_supplycost':l2.ps_supplycost}
+        from  Part as p,
+              (
+            select element {'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'l_quantity':l1.l_quantity,'l_partkey':l1.l_partkey,'l_orderkey':l1.l_orderkey,'n_name':l1.n_name,'ps_supplycost':ps.ps_supplycost}
+            from  Partsupp as ps,
+                  (
+                select element {'l_suppkey':l.l_suppkey,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_quantity':l.l_quantity,'l_partkey':l.l_partkey,'l_orderkey':l.l_orderkey,'n_name':s1.n_name}
+                from  (
+                    select element {'s_suppkey':s.s_suppkey,'n_name':n.n_name}
+                    from  Supplier as s,
+                          Nation as n
+                    where (n.n_nationkey = s.s_nationkey)
+                ) as s1,
+                      LineItem as l
+                where (s1.s_suppkey = l.l_suppkey)
+            ) as l1
+            where ((ps.ps_suppkey = l1.l_suppkey) and (ps.ps_partkey = l1.l_partkey))
+        ) as l2
+        where (tpch.contains(p.p_name,'green') and (p.p_partkey = l2.l_partkey))
+    ) as l3
+    with  amount as ((l3.l_extendedprice * (1 - l3.l_discount)) - (l3.ps_supplycost * l3.l_quantity)),
+          o_year as tpch."get-year"(o.o_orderdate)
+    where (o.o_orderkey = l3.l_orderkey)
+) as profit
+group by profit.nation as nation,profit.o_year as o_year
+order by nation,o_year desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.2.update.sqlpp
new file mode 100644
index 0000000..e5f3d28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.3.query.sqlpp
new file mode 100644
index 0000000..50fb6c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item/q10_returned_item.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 tpch;
+
+
+select element {'c_custkey':c_custkey,'c_name':c_name,'revenue':revenue,'c_acctbal':c_acctbal,'n_name':n_name,'c_address':c_address,'c_phone':c_phone,'c_comment':c_comment}
+from  (
+    select element {'c_custkey':ocn.c_custkey,'c_name':ocn.c_name,'c_acctbal':ocn.c_acctbal,'n_name':ocn.n_name,'c_address':ocn.c_address,'c_phone':ocn.c_phone,'c_comment':ocn.c_comment,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount}
+    from  LineItem as l,
+          (
+        select element {'c_custkey':c.c_custkey,'c_name':c.c_name,'c_acctbal':c.c_acctbal,'n_name':n.n_name,'c_address':c.c_address,'c_phone':c.c_phone,'c_comment':c.c_comment,'o_orderkey':o.o_orderkey}
+        from  Orders as o,
+              Customer as c,
+              Nation as n
+        where (((c.c_custkey = o.o_custkey) and (o.o_orderdate >= '1993-10-01') and (o.o_orderdate < '1994-01-01')) and (c.c_nationkey = n.n_nationkey))
+    ) as ocn
+    where ((l.l_orderkey = ocn.o_orderkey) and (l.l_returnflag = 'R'))
+) as locn
+group by locn.c_custkey as c_custkey,locn.c_name as c_name,locn.c_acctbal as c_acctbal,locn.c_phone as c_phone,locn.n_name as n_name,locn.c_address as c_address,locn.c_comment as c_comment
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  locn as i
+  ))
+order by revenue desc
+limit 20
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
new file mode 100644
index 0000000..50fb6c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.3.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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 tpch;
+
+
+select element {'c_custkey':c_custkey,'c_name':c_name,'revenue':revenue,'c_acctbal':c_acctbal,'n_name':n_name,'c_address':c_address,'c_phone':c_phone,'c_comment':c_comment}
+from  (
+    select element {'c_custkey':ocn.c_custkey,'c_name':ocn.c_name,'c_acctbal':ocn.c_acctbal,'n_name':ocn.n_name,'c_address':ocn.c_address,'c_phone':ocn.c_phone,'c_comment':ocn.c_comment,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount}
+    from  LineItem as l,
+          (
+        select element {'c_custkey':c.c_custkey,'c_name':c.c_name,'c_acctbal':c.c_acctbal,'n_name':n.n_name,'c_address':c.c_address,'c_phone':c.c_phone,'c_comment':c.c_comment,'o_orderkey':o.o_orderkey}
+        from  Orders as o,
+              Customer as c,
+              Nation as n
+        where (((c.c_custkey = o.o_custkey) and (o.o_orderdate >= '1993-10-01') and (o.o_orderdate < '1994-01-01')) and (c.c_nationkey = n.n_nationkey))
+    ) as ocn
+    where ((l.l_orderkey = ocn.o_orderkey) and (l.l_returnflag = 'R'))
+) as locn
+group by locn.c_custkey as c_custkey,locn.c_name as c_name,locn.c_acctbal as c_acctbal,locn.c_phone as c_phone,locn.n_name as n_name,locn.c_address as c_address,locn.c_comment as c_comment
+with  revenue as tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  locn as i
+  ))
+order by revenue desc
+limit 20
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.3.query.sqlpp
new file mode 100644
index 0000000..ea3bd5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q11_important_stock/q11_important_stock.3.query.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.
+ */
+
+use tpch;
+
+
+with  sum as tpch.sum((
+      select element (ps.ps_supplycost * ps.ps_availqty)
+      from  Partsupp as ps,
+            (
+          select element {'s_suppkey':s.s_suppkey}
+          from  Supplier as s,
+                Nation as n
+          where (s.s_nationkey = n.n_nationkey)
+      ) as sn
+      where (ps.ps_suppkey = sn.s_suppkey)
+  ))
+select element {'partkey':t1.ps_partkey,'part_value':t1.part_value}
+from  (
+    select element {'ps_partkey':ps_partkey,'part_value':tpch.sum((
+            select element (i.ps_supplycost * i.ps_availqty)
+            from  ps as i
+        ))}
+    from  Partsupp as ps,
+          (
+        select element {'s_suppkey':s.s_suppkey}
+        from  Supplier as s,
+              Nation as n
+        where (s.s_nationkey = n.n_nationkey)
+    ) as sn
+    where (ps.ps_suppkey = sn.s_suppkey)
+    group by ps.ps_partkey as ps_partkey
+) as t1
+where (t1.part_value > (sum * 0.00001))
+order by t1.part_value desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.3.query.sqlpp
new file mode 100644
index 0000000..61b685e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q12_shipping/q12_shipping.3.query.sqlpp
@@ -0,0 +1,35 @@
+/*
+ * 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 tpch;
+
+
+select element {'l_shipmode':l_shipmode,'high_line_count':tpch.sum((
+        select element tpch."switch-case"(((i.o_orderpriority = '1-URGENT') or (i.o_orderpriority = '2-HIGH')),true,1,false,0)
+        from  o as i
+    )),'low_line_count':tpch.sum((
+        select element tpch."switch-case"(((i.o_orderpriority = '1-URGENT') or (i.o_orderpriority = '2-HIGH')),true,0,false,1)
+        from  o as i
+    ))}
+from  LineItem as l,
+      Orders as o
+where ((o.o_orderkey = l.l_orderkey) and (l.l_commitdate < l.l_receiptdate) and (l.l_shipdate < l.l_commitdate) and (l.l_receiptdate >= '1994-01-01') and (l.l_receiptdate < '1995-01-01') and ((l.l_shipmode = 'MAIL') or (l.l_shipmode = 'SHIP')))
+group by l.l_shipmode as l_shipmode
+order by l_shipmode
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
new file mode 100644
index 0000000..afa7c9b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.3.query.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 tpch;
+
+
+set "import-private-functions" "true";
+
+select element {'c_count':c_count,'custdist':custdist}
+from  (
+    select element {'c_custkey':c_custkey,'c_count':tpch.sum((
+            select element i.o_orderkey_count
+            from  co as i
+        ))}
+    from  (
+        select element {'c_custkey':c.c_custkey,'o_orderkey_count':tpch.count((
+                select element o.o_orderkey
+                from  Orders as o
+                where ((c.c_custkey = o.o_custkey) and tpch.not(tpch.like(o.o_comment,'%special%requests%')))
+            ))}
+        from  Customer as c
+    ) as co
+    group by co.c_custkey as c_custkey
+) as gco
+group by gco.c_count as c_count
+with  custdist as tpch.count(gco)
+order by custdist desc,c_count desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.3.query.sqlpp
new file mode 100644
index 0000000..559dfc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.3.query.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.
+ */
+
+use tpch;
+
+
+select element (100.0 * tpch.sum((
+      select element tpch."switch-case"(tpch.like(i.p_type,'PROMO%'),true,(i.l_extendedprice * (1 - i.l_discount)),false,0.0)
+      from  l as i
+  )) / tpch.sum((
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  )))
+from  LineItem as l,
+      Part as p
+where ((l.l_partkey = p.p_partkey) and (l.l_shipdate >= '1995-09-01') and (l.l_shipdate < '1995-10-01'))
+group by 1 as t
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.3.query.sqlpp
new file mode 100644
index 0000000..e21104b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q15_top_supplier/q15_top_supplier.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 tpch;
+
+
+declare function revenue() {
+(
+    select element {'supplier_no':l_suppkey,'total_revenue':tpch.sum((
+            select element (i.l_extendedprice * (1 - i.l_discount))
+            from  l as i
+        ))}
+    from  LineItem as l
+    where ((l.l_shipdate >= '1996-01-01') and (l.l_shipdate < '1996-04-01'))
+    group by l.l_suppkey as l_suppkey
+)
+};
+with  m as tpch.max((
+      select element r2.total_revenue
+      from  tpch.revenue() as r2
+  ))
+select element {'s_suppkey':s.s_suppkey,'s_name':s.s_name,'s_address':s.s_address,'s_phone':s.s_phone,'total_revenue':r.total_revenue}
+from  Supplier as s,
+      tpch.revenue() as r
+where ((s.s_suppkey = r.supplier_no) and (r.total_revenue < (m + 0.000000001)) and (r.total_revenue > (m - 0.000000001)))
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
new file mode 100644
index 0000000..cc4d01a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.query.sqlpp
@@ -0,0 +1,49 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp() {
+(
+    select element {'p_brand':psp.p_brand,'p_type':psp.p_type,'p_size':psp.p_size,'ps_suppkey':psp.ps_suppkey}
+    from  (
+        select element {'p_brand':p.p_brand,'p_type':p.p_type,'p_size':p.p_size,'ps_suppkey':ps.ps_suppkey}
+        from  Partsupp as ps,
+              Part as p
+        where ((p.p_partkey = ps.ps_partkey) and (p.p_brand != 'Brand#45') and tpch.not(tpch.like(p.p_type,'MEDIUM POLISHED%')))
+    ) as psp,
+          Supplier as s
+    where ((psp.ps_suppkey = s.s_suppkey) and tpch.not(tpch.like(s.s_comment,'%Customer%Complaints%')))
+)
+};
+select element {'p_brand':p_brand,'p_type':p_type,'p_size':p_size,'supplier_cnt':supplier_cnt}
+from  (
+    select element {'p_brand':p_brand1,'p_type':p_type1,'p_size':p_size1,'ps_suppkey':ps_suppkey1}
+    from  tpch.tmp() as t
+    where ((t.p_size = 49) or (t.p_size = 14) or (t.p_size = 23) or (t.p_size = 45) or (t.p_size = 19) or (t.p_size = 3) or (t.p_size = 36) or (t.p_size = 9))
+    group by t.p_brand as p_brand1,t.p_type as p_type1,t.p_size as p_size1,t.ps_suppkey as ps_suppkey1
+) as t2
+group by t2.p_brand as p_brand,t2.p_type as p_type,t2.p_size as p_size
+with  supplier_cnt as tpch.count((
+      select element i.ps_suppkey
+      from  t2 as i
+  ))
+order by supplier_cnt desc,p_brand,p_type,p_size
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.3.query.sqlpp
new file mode 100644
index 0000000..ada4f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.3.query.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 tpch;
+
+
+select element {'t_partkey':l_partkey,'t_count':tpch.count(l),'t_avg_quantity':(0.2 * tpch.avg((
+          select element i.l_quantity
+          from  l as i
+      ))),'t_max_suppkey':tpch.max((
+        select element i.l_suppkey
+        from  l as i
+    )),'t_max_linenumber':tpch.max((
+        select element i.l_linenumber
+        from  l as i
+    )),'t_avg_extendedprice':tpch.avg((
+        select element i.l_extendedprice
+        from  l as i
+    )),'t_avg_discount':tpch.avg((
+        select element i.l_discount
+        from  l as i
+    )),'t_avg_tax':tpch.avg((
+        select element i.l_tax
+        from  l as i
+    )),'t_max_shipdate':tpch.max((
+        select element i.l_shipdate
+        from  l as i
+    )),'t_min_commitdate':tpch.min((
+        select element i.l_commitdate
+        from  l as i
+    )),'t_min_receiptdate':tpch.min((
+        select element i.l_receiptdate
+        from  l as i
+    )),'t_max_comment':tpch.max((
+        select element i.l_comment
+        from  l as i
+    ))}
+from  LineItem as l
+group by l.l_partkey as l_partkey
+order by l_partkey
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.sqlpp
new file mode 100644
index 0000000..2a24bd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.query.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.
+ */
+
+use tpch;
+
+
+declare function tmp() {
+(
+    select element {'t_partkey':l_partkey,'t_avg_quantity':(0.2 * tpch.avg((
+              select element i.l_quantity
+              from  l as i
+          )))}
+    from  LineItem as l
+    group by l.l_partkey as l_partkey
+)
+};
+select element (tpch.sum((
+      select element l.l_extendedprice
+      from  LineItem as l,
+            Part as p,
+            tpch.tmp() as t
+      where (((p.p_partkey = l.l_partkey) and (p.p_container = 'MED BOX')) and ((l.l_partkey = t.t_partkey) and (l.l_quantity < t.t_avg_quantity)))
+  )) / 7.0);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
new file mode 100644
index 0000000..15081ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 tpch;
+
+
+select element {'c_name':c_name,'c_custkey':c_custkey,'o_orderkey':o_orderkey,'o_orderdate':o_orderdate,'o_totalprice':o_totalprice,'sum_quantity':tpch.sum((
+        select element j.l_quantity
+        from  l as j
+    ))}
+from  Customer as c,
+      Orders as o,
+      (
+    select element {'l_orderkey':l_orderkey,'t_sum_quantity':tpch.sum((
+            select element i.l_quantity
+            from  l as i
+        ))}
+    from  LineItem as l
+    group by l.l_orderkey as l_orderkey
+) as t,
+      LineItem as l
+where ((c.c_custkey = o.o_custkey) and ((o.o_orderkey = t.l_orderkey) and (t.t_sum_quantity > 30)) and (l.l_orderkey = o.o_orderkey))
+group by c.c_name as c_name,c.c_custkey as c_custkey,o.o_orderkey as o_orderkey,o.o_orderdate as o_orderdate,o.o_totalprice as o_totalprice
+order by o_totalprice desc,o_orderdate
+limit 100
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
new file mode 100644
index 0000000..7065f87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use tpch;
+
+
+set "import-private-functions" "true";
+
+select element tpch.sum((
+    select element (l.l_extendedprice * (1 - l.l_discount))
+    from  LineItem as l,
+          Part as p
+    where ((p.p_partkey = l.l_partkey) and (((p.p_brand = 'Brand#12') and tpch."reg-exp"(p.p_container,'SM CASE||SM BOX||SM PACK||SM PKG') and (l.l_quantity >= 1) and (l.l_quantity <= 11) and (p.p_size >= 1) and (p.p_size <= 5) and tpch."reg-exp"(l.l_shipmode,'AIR||AIR REG') and (l.l_shipinstruct = 'DELIVER IN PERSON')) or ((p.p_brand = 'Brand#23') and tpch."reg-exp"(p.p_container,'MED BAG||MED BOX||MED PKG||MED PACK') and (l.l_quantity >= 10) and (l.l_quantity <= 20) and (p.p_size >= 1) and (p.p_size <= 10) and tpch."reg-exp"(l.l_shipmode,'AIR||AIR REG') and (l.l_shipinstruct = 'DELIVER IN PERSON')) or ((p.p_brand = 'Brand#34') and tpch."reg-exp"(p.p_container,'LG CASE||LG BOX||LG PACK||LG PKG') and (l.l_quantity >= 20) and (l.l_quantity <= 30) and (p.p_size >= 1) and (p.p_size <= 15) and tpch."reg-exp"(l.l_shipmode,'AIR||AIR REG') and (l.l_shipinstruct = 'DELIVER IN PERSON'))))
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.sqlpp
new file mode 100644
index 0000000..31810e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.query.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.
+ */
+
+use tpch;
+
+
+select element {'s_name':t4.s_name,'s_address':t4.s_address}
+from  (
+    select element {'ps_suppkey':pst1.ps_suppkey}
+    from  (
+        select element {'l_partkey':l_partkey,'l_suppkey':l_suppkey,'sum_quantity':(0.5 * tpch.sum((
+                  select element i.l_quantity
+                  from  l as i
+              )))}
+        from  LineItem as l
+        group by l.l_partkey as l_partkey,l.l_suppkey as l_suppkey
+    ) as t2,
+          (
+        select element {'ps_suppkey':ps.ps_suppkey,'ps_partkey':ps.ps_partkey,'ps_availqty':ps.ps_availqty}
+        from  Partsupp as ps,
+              (
+            select element {'p_partkey':p.p_partkey}
+            from  Part as p
+        ) as t1
+        where (ps.ps_partkey = t1.p_partkey)
+    ) as pst1
+    where ((pst1.ps_partkey = t2.l_partkey) and (pst1.ps_suppkey = t2.l_suppkey) and (pst1.ps_availqty > t2.sum_quantity))
+) as t3,
+      (
+    select element {'s_name':s.s_name,'s_address':s.s_address,'s_suppkey':s.s_suppkey}
+    from  Nation as n,
+          Supplier as s
+    where (s.s_nationkey = n.n_nationkey)
+) as t4
+where (t3.ps_suppkey = t4.s_suppkey)
+order by t4.s_name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ddl.sqlpp
new file mode 100644
index 0000000..907be7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : int64,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int64,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int64,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int64,
+  ps_suppkey : int64,
+  ps_availqty : int64,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
new file mode 100644
index 0000000..5382019
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.query.sqlpp
@@ -0,0 +1,80 @@
+/*
+ * 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 tpch;
+
+
+declare function tmp1() {
+(
+    select element {'l_orderkey':l_orderkey,'count_suppkey':tpch.count((
+            select element i.l_suppkey
+            from  l2 as i
+        )),'max_suppkey':tpch.max((
+            select element i.l_suppkey
+            from  l2 as i
+        ))}
+    from  (
+        select element {'l_orderkey':l_orderkey1,'l_suppkey':l_suppkey1}
+        from  LineItem as l
+        group by l.l_orderkey as l_orderkey1,l.l_suppkey as l_suppkey1
+    ) as l2
+    group by l2.l_orderkey as l_orderkey
+)
+};
+declare function tmp2() {
+(
+    select element {'l_orderkey':l_orderkey,'count_suppkey':tpch.count((
+            select element i.l_suppkey
+            from  l2 as i
+        )),'max_suppkey':tpch.max((
+            select element i.l_suppkey
+            from  l2 as i
+        ))}
+    from  (
+        select element {'l_orderkey':l_orderkey1,'l_suppkey':l_suppkey1}
+        from  LineItem as l
+        where (l.l_receiptdate > l.l_commitdate)
+        group by l.l_orderkey as l_orderkey1,l.l_suppkey as l_suppkey1
+    ) as l2
+    group by l2.l_orderkey as l_orderkey
+)
+};
+select element {'s_name':s_name,'numwait':numwait}
+from  (
+    select element {'s_name':t3.s_name,'l_suppkey':t3.l_suppkey,'l_orderkey':t2.l_orderkey,'count_suppkey':t2.count_suppkey,'max_suppkey':t2.max_suppkey}
+    from  (
+        select element {'s_name':ns.s_name,'l_orderkey':t1.l_orderkey,'l_suppkey':l.l_suppkey}
+        from  LineItem as l,
+              (
+            select element {'s_name':s.s_name,'s_suppkey':s.s_suppkey}
+            from  Nation as n,
+                  Supplier as s
+            where (s.s_nationkey = n.n_nationkey)
+        ) as ns,
+              Orders as o,
+              tpch.tmp1() as t1
+        where (((ns.s_suppkey = l.l_suppkey) and (l.l_receiptdate > l.l_commitdate)) and (o.o_orderkey = l.l_orderkey) and (l.l_orderkey = t1.l_orderkey))
+    ) as t3,
+          tpch.tmp2() as t2
+    where ((t2.count_suppkey >= 0) and (t3.l_orderkey = t2.l_orderkey))
+) as t4
+group by t4.s_name as s_name
+with  numwait as tpch.count(t4)
+order by numwait desc,s_name
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ddl.sqlpp
new file mode 100644
index 0000000..176cdc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ddl.sqlpp
@@ -0,0 +1,134 @@
+/*
+ * 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 tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.2.update.sqlpp
new file mode 100644
index 0000000..2df1357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.2.update.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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 tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
new file mode 100644
index 0000000..6136008
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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 tpch;
+
+
+declare function q22_customer_tmp() {
+(
+    select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':tpch.substring(c.c_phone,1,2)}
+    from  Customer as c
+)
+};
+with  avg as tpch.avg((
+      select element c.c_acctbal
+      from  Customer as c
+      where (c.c_acctbal > 0.0)
+  ))
+select element {'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.sum((
+        select element i.c_acctbal
+        from  ct as i
+    ))}
+from  tpch.q22_customer_tmp() as ct
+where (ct.c_acctbal > avg)
+group by ct.cntrycode as cntrycode
+order by cntrycode
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.1.ddl.sqlpp
new file mode 100644
index 0000000..9447c79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.1.ddl.sqlpp
@@ -0,0 +1,140 @@
+/*
+ * 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  : This test case is to verify the fix for issue562
+ * https://code.google.com/p/asterixdb/issues/detail?id=562
+ * Expected Res : SUCCESS
+ * Date         : 15th Jan. 2015
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Part(PartType) primary key p_partkey;
+
+create  table Partsupp(PartSuppType) primary key ps_partkey,ps_suppkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.2.update.sqlpp
new file mode 100644
index 0000000..828817c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.2.update.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : This test case is to verify the fix for issue562
+ * https://code.google.com/p/asterixdb/issues/detail?id=562
+ * Expected Res : SUCCESS
+ * Date         : 15th Jan. 2015
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Part using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Partsupp using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp
new file mode 100644
index 0000000..ac54a30
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : This test case is to verify the fix for issue562
+ * https://code.google.com/p/asterixdb/issues/detail?id=562
+ * Expected Res : SUCCESS
+ * Date         : 15th Jan. 2015
+ */
+
+use tpch;
+
+
+declare function q22_customer_tmp() {
+(
+    select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':phone_substr}
+    from  Customer as c
+    with  phone_substr as tpch.substring(c.c_phone,1,2)
+    where ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17'))
+)
+};
+with  avg as tpch.avg((
+      select element c.c_acctbal
+      from  Customer as c
+      with  phone_substr as tpch.substring(c.c_phone,1,2)
+      where ((c.c_acctbal > 0.0) and ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17')))
+  ))
+select element {'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.sum((
+        select element i.c_acctbal
+        from  ct as i
+    ))}
+from  tpch.q22_customer_tmp() as ct
+where (tpch.count((
+    select element o
+    from  Orders as o
+    where (ct.c_custkey = o.o_custkey)
+)) = 0)
+group by ct.cntrycode as cntrycode
+order by cntrycode
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.1.ddl.sqlpp
new file mode 100644
index 0000000..8a4e320
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int64,
+  l_partkey : int64,
+  l_suppkey : int64,
+  l_linenumber : int64,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.2.update.sqlpp
new file mode 100644
index 0000000..8aaed2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.3.query.sqlpp
new file mode 100644
index 0000000..efe6954
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue601/query-issue601.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue601
+ * https://code.google.com/p/asterixdb/issues/detail?id=601
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct 2014
+ */
+
+use tpch;
+
+
+select element {'l_linenumber':l_linenumber,'count_order':tpch.count(l)}
+from  LineItem as l
+group by l.l_linenumber as l_linenumber
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.1.ddl.sqlpp
new file mode 100644
index 0000000..508dfeb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.1.ddl.sqlpp
@@ -0,0 +1,140 @@
+/*
+ * 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  : This test case is to verify the fix for issue638
+ * https://code.google.com/p/asterixdb/issues/detail?id=638
+ * Expected Res : SUCCESS
+ * Date         : 24th Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : int32,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create type tpch.PartType as
+ closed {
+  p_partkey : int32,
+  p_name : string,
+  p_mfgr : string,
+  p_brand : string,
+  p_type : string,
+  p_size : int32,
+  p_container : string,
+  p_retailprice : double,
+  p_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create external  table LineItem(LineItemType) using "localfs"(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Orders(OrderType) using "localfs"(("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Supplier(SupplierType) using "localfs"(("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Region(RegionType) using "localfs"(("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Nation(NationType) using "localfs"(("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Part(PartType) using "localfs"(("path"="nc1://data/tpch0.001/part.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Partsupp(PartSuppType) using "localfs"(("path"="nc1://data/tpch0.001/partsupp.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+create external  table Customer(CustomerType) using "localfs"(("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.2.update.sqlpp
new file mode 100644
index 0000000..86538e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue638
+ * https://code.google.com/p/asterixdb/issues/detail?id=638
+ * Expected Res : SUCCESS
+ * Date         : 24th Oct. 2014
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.3.query.sqlpp
new file mode 100644
index 0000000..6c14062
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue638/query-issue638.3.query.sqlpp
@@ -0,0 +1,63 @@
+/*
+ * 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  : This test case is to verify the fix for issue638
+ * https://code.google.com/p/asterixdb/issues/detail?id=638
+ * Expected Res : SUCCESS
+ * Date         : 24th Oct. 2014
+ */
+
+use tpch;
+
+
+select element {'nation':nation,'o_year':o_year,'sum_profit':tpch.sum((
+        select element pr.amount
+        from  profit as pr
+    ))}
+from  (
+    select element {'nation':l3.n_name,'o_year':o_year,'amount':amount}
+    from  Orders as o,
+          (
+        select element {'l_extendedprice':l2.l_extendedprice,'l_discount':l2.l_discount,'l_quantity':l2.l_quantity,'l_orderkey':l2.l_orderkey,'n_name':l2.n_name,'ps_supplycost':l2.ps_supplycost}
+        from  Part as p,
+              (
+            select element {'l_extendedprice':l1.l_extendedprice,'l_discount':l1.l_discount,'l_quantity':l1.l_quantity,'l_partkey':l1.l_partkey,'l_orderkey':l1.l_orderkey,'n_name':l1.n_name,'ps_supplycost':ps.ps_supplycost}
+            from  Partsupp as ps,
+                  (
+                select element {'l_suppkey':l.l_suppkey,'l_extendedprice':l.l_extendedprice,'l_discount':l.l_discount,'l_quantity':l.l_quantity,'l_partkey':l.l_partkey,'l_orderkey':l.l_orderkey,'n_name':s1.n_name}
+                from  (
+                    select element {'s_suppkey':s.s_suppkey,'n_name':n.n_name}
+                    from  Supplier as s,
+                          Nation as n
+                    where (n.n_nationkey = s.s_nationkey)
+                ) as s1,
+                      LineItem as l
+                where (s1.s_suppkey = l.l_suppkey)
+            ) as l1
+            where ((ps.ps_suppkey = l1.l_suppkey) and (ps.ps_partkey = l1.l_partkey))
+        ) as l2
+        where (tpch.contains(p.p_name,'green') and (p.p_partkey = l2.l_partkey))
+    ) as l3
+    with  amount as ((l3.l_extendedprice * (1 - l3.l_discount)) - (l3.ps_supplycost * l3.l_quantity)),
+          o_year as tpch."get-year"(o.o_orderdate)
+    where (o.o_orderkey = l3.l_orderkey)
+) as profit
+group by profit.nation as nation,profit.o_year as o_year
+order by nation,o_year desc
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.1.ddl.sqlpp
new file mode 100644
index 0000000..18e3fa1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.2.update.sqlpp
new file mode 100644
index 0000000..f355804
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.3.query.sqlpp
new file mode 100644
index 0000000..2cad6ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785-2/query-issue785-2.3.query.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+with  t as (
+      select element {'n_nationkey':nation.n_nationkey,'n_name':nation.n_name}
+      from  Nation as nation,
+            SelectedNation as sn
+      where (nation.n_nationkey = sn.n_nationkey)
+  ),
+      X as (
+      select element {'nation_key':nation_key,'order_date':orderdate,'sum_price':sum}
+      from  t as n,
+            Customer as customer,
+            Orders as orders
+      where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = n.n_nationkey))
+      group by orders.o_orderdate as orderdate,n.n_nationkey as nation_key
+      with  sum as tpch.sum((
+            select element o.o_totalprice
+            from  orders as o
+        ))
+  )
+select element {'nation_key':nation_key,'sum_price':(
+        select element {'orderdate':y.order_date,'sum_price':y.sum_price}
+        from  x as y
+        order by y.sum_price desc
+        limit 3
+    )}
+from  X as x
+group by x.nation_key as nation_key
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.1.ddl.sqlpp
new file mode 100644
index 0000000..18e3fa1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int64,
+  o_custkey : int64,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int64,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int64,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int64,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int64,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int64,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int64,
+  n_name : string,
+  n_regionkey : int64,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int64,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.2.update.sqlpp
new file mode 100644
index 0000000..f355804
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.3.query.sqlpp
new file mode 100644
index 0000000..ed649ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue785/query-issue785.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue785
+ * https://code.google.com/p/asterixdb/issues/detail?id=785
+ * Expected Res : SUCCESS
+ * Date         : 2nd Oct. 2014
+ */
+
+use tpch;
+
+
+select element {'nation_key':nation_key,'sum_price':(
+        select element {'orderdate':od,'sum_price':sum}
+        from  x as i
+        group by i.order_date as od
+        with  sum as tpch.sum((
+              select element s.sum_price
+              from  i as s
+          ))
+        order by sum desc
+        limit 3
+    )}
+from  (
+    select element {'nation_key':nation_key,'order_date':orderdate,'sum_price':tpch.sum((
+            select element o.o_totalprice
+            from  orders as o
+        ))}
+    from  Nation as n,
+          Customer as customer,
+          Orders as orders
+    where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = n.n_nationkey))
+    group by orders.o_orderdate as orderdate,n.n_nationkey as nation_key
+) as x
+group by x.nation_key as nation_key
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.1.ddl.sqlpp
new file mode 100644
index 0000000..33f5419
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.1.ddl.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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  : This test case is to verify the fix for issue786
+ * https://code.google.com/p/asterixdb/issues/detail?id=786
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : int32,
+  s_name : string,
+  s_address : string,
+  s_nationkey : int32,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+}
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : int32,
+  n_name : string,
+  n_regionkey : int32,
+  n_comment : string
+}
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : int32,
+  r_name : string,
+  r_comment : string
+}
+
+create  table Orders(OrderType) primary key o_orderkey;
+
+create  table Supplier(SupplierType) primary key s_suppkey;
+
+create  table Region(RegionType) primary key r_regionkey;
+
+create  table Nation(NationType) primary key n_nationkey;
+
+create  table Customer(CustomerType) primary key c_custkey;
+
+create  table SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.2.update.sqlpp
new file mode 100644
index 0000000..ffc0e04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.2.update.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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  : This test case is to verify the fix for issue786
+ * https://code.google.com/p/asterixdb/issues/detail?id=786
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct. 2014
+ */
+
+use tpch;
+
+
+load  table Orders using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Supplier using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/supplier.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Region using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/region.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Nation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/nation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table Customer using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/customer.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
+load  table SelectedNation using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/selectednation.tbl"),("format"="delimited-text"),("delimiter"="|"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.3.query.sqlpp
new file mode 100644
index 0000000..dead643
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue786/query-issue786.3.query.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : This test case is to verify the fix for issue786
+ * https://code.google.com/p/asterixdb/issues/detail?id=786
+ * Expected Res : SUCCESS
+ * Date         : 10th Oct. 2014
+ */
+
+use tpch;
+
+
+select element {'nation_key':nation.n_nationkey,'name':nation.n_name,'aggregates':(
+        select element {'order_date':orderdate,'sum_price':sum}
+        from  Orders as orders,
+              Customer as customer
+        where ((orders.o_custkey = customer.c_custkey) and (customer.c_nationkey = nation.n_nationkey))
+        group by orders.o_orderdate as orderdate
+        with  sum as tpch.sum((
+              select element o.o_totalprice
+              from  orders as o
+          ))
+        order by sum desc
+        limit 3
+    )}
+from  Nation as nation,
+      SelectedNation as sn
+where (nation.n_nationkey = sn.sn_nationkey)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.1.ddl.sqlpp
new file mode 100644
index 0000000..b26ac3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.2.update.sqlpp
new file mode 100644
index 0000000..d3810ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.3.query.sqlpp
new file mode 100644
index 0000000..16d3fe0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-2/query-issue810-2.3.query.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'count_cheaps':tpch.count(cheaps),'total_charges':tpch.sum(charges)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+with  cheaps as (
+      select element m
+      from  l as m
+      where (m.l_discount > 0.05)
+  ),
+      charges as (
+      select element (a.l_extendedprice * (1 - a.l_discount) * (1 + a.l_tax))
+      from  l as a
+  )
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.1.ddl.sqlpp
new file mode 100644
index 0000000..b26ac3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.2.update.sqlpp
new file mode 100644
index 0000000..d3810ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.3.query.sqlpp
new file mode 100644
index 0000000..576192d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810-3/query-issue810-3.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'count_cheaps':tpch.count(cheaps),'avg_expensive_discounts':tpch.avg(expensives),'sum_disc_prices':tpch.sum(disc_prices),'total_charges':tpch.sum(charges)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+with  expensives as (
+      select element i.l_discount
+      from  l as i
+      where (i.l_discount <= 0.05)
+  ),
+      cheaps as (
+      select element i
+      from  l as i
+      where (i.l_discount > 0.05)
+  ),
+      charges as (
+      select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+      from  l as i
+  ),
+      disc_prices as (
+      select element (i.l_extendedprice * (1 - i.l_discount))
+      from  l as i
+  )
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.1.ddl.sqlpp
new file mode 100644
index 0000000..b26ac3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.2.update.sqlpp
new file mode 100644
index 0000000..d3810ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.3.query.sqlpp
new file mode 100644
index 0000000..01e1654
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue810/query-issue810.3.query.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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  : This test case is to verify the fix for issue810
+ * https://code.google.com/p/asterixdb/issues/detail?id=810
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+select element {'l_returnflag':l_returnflag,'l_linestatus':l_linestatus,'count_cheaps':tpch.count(cheap),'count_expensives':tpch.count(expensive)}
+from  LineItem as l
+where (l.l_shipdate <= '1998-09-02')
+/* +hash */
+group by l.l_returnflag as l_returnflag,l.l_linestatus as l_linestatus
+with  cheap as (
+      select element m
+      from  l as m
+      where (m.l_discount > 0.05)
+  ),
+      expensive as (
+      select element a
+      from  l as a
+      where (a.l_discount <= 0.05)
+  )
+order by l_returnflag,l_linestatus
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.1.ddl.sqlpp
new file mode 100644
index 0000000..d6e46e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.2.update.sqlpp
new file mode 100644
index 0000000..9d3e5cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.3.query.sqlpp
new file mode 100644
index 0000000..562f78f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827-2/query-issue827-2.3.query.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 3rd Dec. 2014
+ */
+
+use tpch;
+
+
+{'sum_qty_partial':tpch.sum((
+    select element i.l_quantity
+    from  LineItem as i
+    where (i.l_shipdate <= '1998-09-02')
+)),'sum_base_price':tpch.sum((
+    select element i.l_extendedprice
+    from  LineItem as i
+)),'sum_disc_price':tpch.sum((
+    select element (i.l_extendedprice * (1 - i.l_discount))
+    from  LineItem as i
+)),'sum_charge':tpch.sum((
+    select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
+    from  LineItem as i
+)),'ave_qty':tpch.avg((
+    select element i.l_quantity
+    from  LineItem as i
+    where (i.l_shipdate <= '1998-09-02')
+)),'ave_price':tpch.avg((
+    select element i.l_extendedprice
+    from  LineItem as i
+)),'ave_disc':tpch.avg((
+    select element i.l_discount
+    from  LineItem as i
+)),'count_order':tpch.count((
+    select element l
+    from  LineItem as l
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.1.ddl.sqlpp
new file mode 100644
index 0000000..d6e46e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.2.update.sqlpp
new file mode 100644
index 0000000..9d3e5cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.2.update.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+load  table LineItem using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.3.query.sqlpp
new file mode 100644
index 0000000..d056bcb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue827/query-issue827.3.query.sqlpp
@@ -0,0 +1,38 @@
+/*
+ * 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  : This test case is to verify the fix for issue827
+ * https://code.google.com/p/asterixdb/issues/detail?id=827
+ * Expected Res : SUCCESS
+ * Date         : 16th Nov. 2014
+ */
+
+use tpch;
+
+
+{'count_cheaps':tpch.count((
+    select element l.l_quantity
+    from  LineItem as l
+)),'count_expensives':tpch.sum((
+    select element e
+    from  (
+        select element l.l_extendedprice
+        from  LineItem as l
+    ) as e
+))};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.1.ddl.sqlpp
new file mode 100644
index 0000000..5e79a7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Order by an open-type field
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.3.query.sqlpp
new file mode 100644
index 0000000..8c911b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/opentype_orderby_01/opentype_orderby_01.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+order by emp.supvrid,emp.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.1.ddl.sqlpp
new file mode 100644
index 0000000..882e0bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between a closed-type field (INT64) and a closed-type field (INT64)
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.3.query.sqlpp
new file mode 100644
index 0000000..6b4e88a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.worksince':emp.worksince,'dept.dsince':dept.dsince}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.worksince = dept.dsince)
+order by emp.id,dept.did,emp.worksince,dept.dsince
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.1.ddl.sqlpp
new file mode 100644
index 0000000..f3a4dde
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between a closed-type field (INT64) and a closed-type field (INT32): comparing different types
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.3.query.sqlpp
new file mode 100644
index 0000000..74614f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.worksince':emp.worksince,'dept.bossidint32 + 2000':(dept.bossidint32 + 2000)}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.worksince = (dept.bossidint32 + 2000))
+order by emp.id,emp.worksince,dept.bossidint32,dept.did
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.1.ddl.sqlpp
new file mode 100644
index 0000000..ef2519d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an indexed closed-type field and a non-indexed closed-type field: same type
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.3.query.sqlpp
new file mode 100644
index 0000000..b112b3b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.age':emp.age,'dept.bossid':dept.bossid}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.age = dept.bossid)
+order by emp.id,dept.did,emp.age,dept.bossid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.1.ddl.sqlpp
new file mode 100644
index 0000000..2913bd0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an indexed closed-type field and a non-indexed closed-type field: different types
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.3.query.sqlpp
new file mode 100644
index 0000000..d13592a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.age':emp.age,'dept.bossidint32':dept.bossidint32}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.age = dept.bossidint32)
+order by emp.id,dept.did,emp.age,dept.bossidint32
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.1.ddl.sqlpp
new file mode 100644
index 0000000..42e14de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.1.ddl.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an indexed closed-type field and a non-indexed closed-type field: different types
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dno : int32,
+  dname : string
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.2.update.sqlpp
new file mode 100644
index 0000000..8bfa13c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset_minus_data.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset_minus_data.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.3.query.sqlpp
new file mode 100644
index 0000000..44a792f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.empno':emp.empno,'dept.dno':dept.dno}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.empno = dept.dno)
+order by emp.id,dept.did,emp.empno,dept.dno
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.1.ddl.sqlpp
new file mode 100644
index 0000000..9a4b7ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an indexed closed-type field (INT64) lookup by using an INT8 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.3.query.sqlpp
new file mode 100644
index 0000000..5039b2e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.age':emp.age}
+from  empDataset as emp
+where (emp.age = test.int8('1'))
+order by emp.id,emp.age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.1.ddl.sqlpp
new file mode 100644
index 0000000..43c27d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an indexed closed-type field (INT64) lookup by using an INT16 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.3.query.sqlpp
new file mode 100644
index 0000000..4fb5d2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.age':emp.age}
+from  empDataset as emp
+where (emp.age = test.int16('1'))
+order by emp.id,emp.age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.1.ddl.sqlpp
new file mode 100644
index 0000000..91d1fe2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an indexed closed-type field (INT64) lookup by using an INT32 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.3.query.sqlpp
new file mode 100644
index 0000000..e94b64e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.age':emp.age}
+from  empDataset as emp
+where (emp.age = test.int32('1'))
+order by emp.id,emp.age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.1.ddl.sqlpp
new file mode 100644
index 0000000..437e81a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an indexed closed-type field (INT64) lookup by using an INT64 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.3.query.sqlpp
new file mode 100644
index 0000000..02c3840
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.age':emp.age}
+from  empDataset as emp
+where (emp.age = test.int64('1'))
+order by emp.id,emp.age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.1.ddl.sqlpp
new file mode 100644
index 0000000..bd2f70f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an indexed closed-type field (INT64) lookup by using a FLOAT constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.3.query.sqlpp
new file mode 100644
index 0000000..3577e50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.age':emp.age}
+from  empDataset as emp
+where (emp.age = test.float('1'))
+order by emp.id,emp.age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.1.ddl.sqlpp
new file mode 100644
index 0000000..80631b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an indexed closed-type field (INT64) lookup by using a DOUBLE constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.3.query.sqlpp
new file mode 100644
index 0000000..02c3840
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.age':emp.age}
+from  empDataset as emp
+where (emp.age = test.int64('1'))
+order by emp.id,emp.age
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.1.ddl.sqlpp
new file mode 100644
index 0000000..cded6ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an non-indexed closed-type field (INT64) lookup by using an INT16 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.3.query.sqlpp
new file mode 100644
index 0000000..1f34479
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.worksince':emp.worksince}
+from  empDataset as emp
+where (emp.worksince = test.int16('2001'))
+order by emp.id,emp.worksince
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.1.ddl.sqlpp
new file mode 100644
index 0000000..4fba616
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an non-indexed closed-type field (INT64) lookup by using an INT32 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.3.query.sqlpp
new file mode 100644
index 0000000..768425b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.worksince':emp.worksince}
+from  empDataset as emp
+where (emp.worksince = test.int32('2001'))
+order by emp.id,emp.worksince
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.1.ddl.sqlpp
new file mode 100644
index 0000000..c35ddc3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an non-indexed closed-type field (INT64) lookup by using an INT64 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.3.query.sqlpp
new file mode 100644
index 0000000..96b3a18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.worksince':emp.worksince}
+from  empDataset as emp
+where (emp.worksince = test.int64('2001'))
+order by emp.id,emp.worksince
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.1.ddl.sqlpp
new file mode 100644
index 0000000..201b7a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an non-indexed closed-type field (INT64) lookup by using a FLOAT constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.3.query.sqlpp
new file mode 100644
index 0000000..f9e6e82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.worksince':emp.worksince}
+from  empDataset as emp
+where (emp.worksince = test.float('2001'))
+order by emp.id,emp.worksince
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.1.ddl.sqlpp
new file mode 100644
index 0000000..abbcaa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - an non-indexed closed-type field (INT64) lookup by using a DOUBLE constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.3.query.sqlpp
new file mode 100644
index 0000000..7bf0a98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.worksince':emp.worksince}
+from  empDataset as emp
+where (emp.worksince = test.double('2001'))
+order by emp.id,emp.worksince
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.1.ddl.sqlpp
new file mode 100644
index 0000000..18d6bd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and a non-indexed closed-type field
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.3.query.sqlpp
new file mode 100644
index 0000000..c413bed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'dept.bossid':dept.bossid,'emp.suprvrid':emp.supvrid}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.supvrid = dept.bossid)
+order by emp.id,emp.supvrid,dept.did
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.1.ddl.sqlpp
new file mode 100644
index 0000000..ae862f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.1.ddl.sqlpp
@@ -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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an indexed closed-type field
+* - Same as the comparison_1 except the fact that the left and the right side has been changed
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.3.query.sqlpp
new file mode 100644
index 0000000..05e9bcd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.supvrid':emp.supvrid,'dept.floor':dept.floor}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.supvrid = dept.floor)
+order by emp.id,emp.supvrid,dept.floor,dept.did
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.1.ddl.sqlpp
new file mode 100644
index 0000000..8e3d575
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between a non-indexed closed-type field and an open-type field
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.3.query.sqlpp
new file mode 100644
index 0000000..1ad7c35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'emp.empno':emp.empno,'dept.dmgrid':dept.dmgrid}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.empno = dept.dmgrid)
+order by emp.id,emp.empno,dept.dmgrid,dept.did
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.1.ddl.sqlpp
new file mode 100644
index 0000000..b98cdb8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an indexed closed-type field and an open-type field
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.3.query.sqlpp
new file mode 100644
index 0000000..d44a13f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'dept.did':dept.did,'dept.dmgrid':dept.dmgrid}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.id = dept.dmgrid)
+order by emp.id,dept.did,dept.dmgrid,dept.did
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.1.ddl.sqlpp
new file mode 100644
index 0000000..a84c172
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an INT8 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.3.query.sqlpp
new file mode 100644
index 0000000..80edd7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.int8('1'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.1.ddl.sqlpp
new file mode 100644
index 0000000..fdd828e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an INT16 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.3.query.sqlpp
new file mode 100644
index 0000000..d409929
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.int16('1'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.1.ddl.sqlpp
new file mode 100644
index 0000000..7fd74a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an INT32 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.3.query.sqlpp
new file mode 100644
index 0000000..613f966
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.int32('1'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.1.ddl.sqlpp
new file mode 100644
index 0000000..92560a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an INT64 constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.3.query.sqlpp
new file mode 100644
index 0000000..1b4d183
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.int64('1'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.1.ddl.sqlpp
new file mode 100644
index 0000000..63890ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and a FLOAT constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.3.query.sqlpp
new file mode 100644
index 0000000..818203c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.float('1.0'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.1.ddl.sqlpp
new file mode 100644
index 0000000..47cda3a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and a DOUBLE constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.3.query.sqlpp
new file mode 100644
index 0000000..ae8fcc7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.double('1.0'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.1.ddl.sqlpp
new file mode 100644
index 0000000..ae962cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and a STRING constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.3.query.sqlpp
new file mode 100644
index 0000000..f0d7cc2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = '1')
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.1.ddl.sqlpp
new file mode 100644
index 0000000..b31ab12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and a POINT constant
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.3.query.sqlpp
new file mode 100644
index 0000000..dc1064a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.supvrid':emp.supvrid}
+from  empDataset as emp
+where (emp.supvrid = test.point('80.10d, -10E5'))
+order by emp.id,emp.supvrid
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.1.ddl.sqlpp
new file mode 100644
index 0000000..32fdbcb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.1.ddl.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an open-type field
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.3.query.sqlpp
new file mode 100644
index 0000000..7751c86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.suprvrid':emp.supvrid,'dept.dmgrid2':dept.dmgrid2}
+from  empDataset as emp,
+      deptDataset as dept
+where (emp.supvrid = dept.dmgrid2)
+order by emp.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.1.ddl.sqlpp
new file mode 100644
index 0000000..b2ebae0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.1.ddl.sqlpp
@@ -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.
+ */
+/*
+* Type Promotion Test
+* - Comparison between an open-type field and an open-type field
+* - Same as the comparison_1 except the fact that the left and the right side has been changed
+* - Expected Result: Success
+*/
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.empInfoType as
+{
+  id : int64,
+  empno : int64,
+  name : string,
+  height : float,
+  age : int64,
+  worksince : int64
+}
+
+create type test.deptInfoType as
+{
+  did : int64,
+  dname : string,
+  floor : int64,
+  dsince : int64,
+  bossid : int64,
+  bossidint32 : int32
+}
+
+create  table empDataset(empInfoType) primary key id;
+
+create  table deptDataset(deptInfoType) primary key did;
+
+create  index empAgeIdx  on empDataset (age) type btree;
+
+create  index deptFloorIdx  on deptDataset (floor) type btree;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.2.update.sqlpp
new file mode 100644
index 0000000..14ca751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.2.update.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+load  table empDataset using "localfs" (("path"="nc1://data/types/empDataset.adm"),("format"="adm"));
+
+load  table deptDataset using "localfs" (("path"="nc1://data/types/deptDataset.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.3.query.sqlpp
new file mode 100644
index 0000000..9d854d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.3.query.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.
+ */
+/*
+* Type Promotion Test
+*
+*/
+
+use test;
+
+
+select element {'emp.id':emp.id,'emp.suprvrid':emp.supvrid,'dept.dmgrid2':dept.dmgrid2}
+from  empDataset as emp,
+      deptDataset as dept
+where (dept.dmgrid2 = emp.supvrid)
+order by emp.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/record01/record01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/record01/record01.1.ddl.sqlpp
new file mode 100644
index 0000000..938fe82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/record01/record01.1.ddl.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.
+ */
+
+drop  database local if exists;
+create  database local;
+
+use local;
+
+
+create type local.ttype as
+{
+  id : int32
+}
+
+create  table dset(ttype) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.1.ddl.sqlpp
new file mode 100644
index 0000000..326256a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.1.ddl.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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 TestVerse if exists;
+create  database TestVerse;
+
+use TestVerse;
+
+
+create type TestVerse.Int64TestType as
+{
+  myint64 : int64,
+  myoptint64 : int64?,
+  myint32 : int32,
+  myoptint32 : int32?,
+  myint16 : int16,
+  myoptint16 : int16?,
+  mydouble : double,
+  myoptdouble : double?,
+  myfloat : float,
+  myoptfloat : float?
+}
+
+create  table Int64Test(Int64TestType) primary key myint64;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.2.update.sqlpp
new file mode 100644
index 0000000..7151214
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.2.update.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.
+ */
+
+use TestVerse;
+
+
+insert into Int64Test
+select element {'myint64':TestVerse.int64('13'),'myoptint64':13,'myint32':TestVerse.int8('2'),'myoptint32':TestVerse.int16('3'),'myint16':TestVerse.int8('9'),'myoptint16':TestVerse.int8('10'),'mydouble':TestVerse.float('2.12'),'myoptdouble':TestVerse.int64('32'),'myfloat':TestVerse.int8('9'),'myoptfloat':TestVerse.int32('328')};
+insert into Int64Test
+select element {'myint64':12,'myoptint64':null,'myint32':TestVerse.int8('2'),'myoptint32':TestVerse.date(null),'myint16':TestVerse.int8('9'),'myoptint16':TestVerse."interval-starts"(null,null),'mydouble':TestVerse.float('2.12'),'myoptdouble':TestVerse.time(null),'myfloat':TestVerse.int8('9'),'myoptfloat':TestVerse.datetime(null)};
+insert into Int64Test
+select element {'myint64':TestVerse.int16('11'),'myoptint64':TestVerse.int8('3'),'myint32':TestVerse.int8('2'),'myoptint32':TestVerse.int16('3'),'myint16':TestVerse.int8('9'),'myoptint16':TestVerse.int8('10'),'mydouble':TestVerse.int8('2'),'myoptdouble':TestVerse.int16('32'),'myfloat':TestVerse.int16('9'),'myoptfloat':TestVerse.datetime(null)};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.3.query.sqlpp
new file mode 100644
index 0000000..1a126c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_0/type_promotion_0.3.query.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 TestVerse;
+
+
+select element i
+from  Int64Test as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.1.ddl.sqlpp
new file mode 100644
index 0000000..fe7a398
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.1.ddl.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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 TestDataverse if exists;
+create  database TestDataverse;
+
+use TestDataverse;
+
+
+create type TestDataverse.TestType as
+{
+  id : int64,
+  int8_u : {{int8}},
+  int8_o : [int8],
+  int16_u : {{int16}},
+  int16_o : [int16],
+  int32_u : {{int32}},
+  int32_o : [int32],
+  int64_u : {{int64}},
+  int64_o : [int64],
+  float_u : {{float}},
+  float_o : [float],
+  double_u : {{double}},
+  double_o : [double]
+}
+
+create  table TestSet(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.2.update.sqlpp
new file mode 100644
index 0000000..fa4eb22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.2.update.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 TestDataverse;
+
+
+insert into TestSet
+{'id':1,'int8_u':{{TestDataverse.int8('100')}},'int8_o':[TestDataverse.int8('100')],'int16_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000')}},'int16_o':[TestDataverse.int8('100'),TestDataverse.int16('10000')],'int32_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000}},'int32_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000],'int64_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')}},'int64_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')],'float_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000}},'float_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000],'double_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')}},'double_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.3.query.sqlpp
new file mode 100644
index 0000000..673c735
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_1/type_promotion_1.3.query.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 TestDataverse;
+
+
+select element i
+from  TestSet as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.1.ddl.sqlpp
new file mode 100644
index 0000000..8b7ccc9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.1.ddl.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.
+ */
+
+drop  database TestDataverse if exists;
+create  database TestDataverse;
+
+use TestDataverse;
+
+
+create type TestDataverse.TestType as
+{
+  id : int64,
+  sec_id : int64
+}
+
+create  table TestSet(TestType) primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.2.update.sqlpp
new file mode 100644
index 0000000..fa4eb22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.2.update.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 TestDataverse;
+
+
+insert into TestSet
+{'id':1,'int8_u':{{TestDataverse.int8('100')}},'int8_o':[TestDataverse.int8('100')],'int16_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000')}},'int16_o':[TestDataverse.int8('100'),TestDataverse.int16('10000')],'int32_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000}},'int32_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000],'int64_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')}},'int64_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')],'float_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000}},'float_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000],'double_u':{{TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')}},'double_o':[TestDataverse.int8('100'),TestDataverse.int16('10000'),1000000,TestDataverse.int64('10000000000')]};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.3.query.sqlpp
new file mode 100644
index 0000000..673c735
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/type_promotion_open_index_enforced/type_promotion_open_index_enforced.3.query.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 TestDataverse;
+
+
+select element i
+from  TestSet as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.1.ddl.sqlpp
new file mode 100644
index 0000000..e46f182
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.1.ddl.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.
+ */
+
+drop  database TinySocial if exists;
+create  database TinySocial;
+
+use TinySocial;
+
+
+create type TinySocial.FacebookUserType as
+{
+  id : int64
+}
+
+create type TinySocial.FacebookMessageType as
+{
+  "message-id" : int64
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.2.update.sqlpp
new file mode 100644
index 0000000..2eb3732
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.2.update.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.
+ */
+
+use TinySocial;
+
+
+load  table FacebookUsers using "localfs" (("path"="nc1://data/tinysocial/fbu.adm"),("format"="adm"));
+
+load  table FacebookMessages using "localfs" (("path"="nc1://data/tinysocial/fbm.adm"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.3.query.sqlpp
new file mode 100644
index 0000000..e544602
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union/union.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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 TinySocial;
+
+
+with  t1 as (
+      select element t.id
+      from  FacebookUsers as t
+  ),
+      t2 as (
+      select element s."message-id"
+      from  FacebookMessages as s
+  ),
+      c as t1
+      union
+      t2
+select element res
+from  c as res
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.1.ddl.sqlpp
new file mode 100644
index 0000000..41b0fb3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.1.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Invoke a built-in function with incorrect number of arguments
+ * Expected Res : Failure
+ * Date         : Nov 13th 2012
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.2.update.sqlpp
new file mode 100644
index 0000000..bcba97b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.2.update.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.
+ */
+/*
+ * Description  : Invoke a built-in function with incorrect number of arguments
+ * Expected Res : Failure
+ * Date         : Nov 13th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.3.query.sqlpp
new file mode 100644
index 0000000..908405d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/f01/f01.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Invoke a built-in function with incorrect number of arguments
+ * Expected Res : Failure
+ * Date         : Nov 13th 2012
+ */
+
+use test;
+
+
+test.int8();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.1.ddl.sqlpp
new file mode 100644
index 0000000..8eda615
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Invoke a private function (internal to Asterix) without setting the 'import-private-functions' flag as true
+ * Expected Res : Failure (Unknown Function)
+ * Date         : 18th May 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.3.query.sqlpp
new file mode 100644
index 0000000..2db233e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.3.query.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.
+ */
+
+use test;
+
+
+with  a as [],
+      b as ['abc','bcd','cde','def','efg'],
+      c as ['abc','bcd','cde','def','efg','hij','ijk'],
+      d as ['abc','bcd','cde','def','efg','fgh','ghi','hij','ijk','jkl'],
+      e as ['efg','abc','cde','def','hij','ijk','bcd'],
+      f as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      g as ['Efg','aBc','cdE','DEf','hIJ','IjK','BCD'],
+      h as ['abc','ijk','bcd','efg','fgh','ghi','def','hij','jkl','cde'],
+      results as [test."similarity-jaccard"(a,b),test."similarity-jaccard"(b,a),test."similarity-jaccard"(c,d),test."similarity-jaccard"(d,c),test."similarity-jaccard"(e,f),test."similarity-jaccard"(f,e),test."similarity-jaccard"(g,h),test."similarity-jaccard"(h,g)]
+select element i
+from  results as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.1.ddl.sqlpp
new file mode 100644
index 0000000..4055b6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue172
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.2.update.sqlpp
new file mode 100644
index 0000000..4055b6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue172
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.3.query.sqlpp
new file mode 100644
index 0000000..efc282e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue172/query-issue172.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue172
+
+"string-length"("string-concat"(['this is a ','test string']));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.1.ddl.sqlpp
new file mode 100644
index 0000000..d0baf5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue201
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.2.update.sqlpp
new file mode 100644
index 0000000..d0baf5c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue201
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.3.query.sqlpp
new file mode 100644
index 0000000..13599da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue201/query-issue201.3.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : This test case is to verify the fix for issue201
+
+set "import-private-functions" "true";
+
+with  x as range(1,100)
+select element i
+from  x as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.1.ddl.sqlpp
new file mode 100644
index 0000000..d096df2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue218
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.2.update.sqlpp
new file mode 100644
index 0000000..d096df2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue218
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.query.sqlpp
new file mode 100644
index 0000000..cd4b50b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue218
+
+select element test.computeBonus(-1,-1);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.1.ddl.sqlpp
new file mode 100644
index 0000000..d096df2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue218
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.2.update.sqlpp
new file mode 100644
index 0000000..d096df2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue218
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.3.query.sqlpp
new file mode 100644
index 0000000..d79091d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue218/query-issue218.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue218
+
+1;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.1.ddl.sqlpp
new file mode 100644
index 0000000..459920d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue244
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.2.update.sqlpp
new file mode 100644
index 0000000..f33d37d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.2.update.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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  : This test case is to verify the fix for issue244
+
+use test;
+
+
+insert into t1
+select element {'id':21,'name':'John'};
+insert into t1
+select element {'id':34,'name':'Bill'};
+insert into t1
+select element {'id':41,'name':'Joy'};
+insert into t1
+select element {'id':16,'name':'Sam'};
+insert into t1
+select element {'id':67,'name':'Ravi'};
+insert into t2
+select element test.f1();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.3.query.sqlpp
new file mode 100644
index 0000000..70465cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue244/query-issue244.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue244
+
+use test;
+
+
+select element l
+from  t2 as l
+order by l.id
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.1.ddl.sqlpp
new file mode 100644
index 0000000..01967d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 455
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.2.update.sqlpp
new file mode 100644
index 0000000..01967d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.2.update.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 455
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.3.query.sqlpp
new file mode 100644
index 0000000..d781753
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.3.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 455
+
+select element printName();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.4.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.4.ddl.sqlpp
new file mode 100644
index 0000000..487fd1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.4.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 455
+
+drop function test.printName@0;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.5.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.5.query.sqlpp
new file mode 100644
index 0000000..7abd45d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue455/query-issue455.5.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 455
+
+select element l
+from  "Metadata.Function" as l
+;
+select element printName();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.1.ddl.sqlpp
new file mode 100644
index 0000000..c1f21ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.1.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 489
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.2.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.2.query.sqlpp
new file mode 100644
index 0000000..658e62f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.2.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 489
+
+select element count((
+    select element x
+    from  "Metadata.Function" as x
+    where (x.DataverseName = 'test')
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.3.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.3.ddl.sqlpp
new file mode 100644
index 0000000..7125d8d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.3.ddl.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 489
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.4.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.4.query.sqlpp
new file mode 100644
index 0000000..658e62f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/query-issue489/query-issue489.4.query.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.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue 489
+
+select element count((
+    select element x
+    from  "Metadata.Function" as x
+    where (x.DataverseName = 'test')
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.1.ddl.sqlpp
new file mode 100644
index 0000000..12226f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.1.ddl.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.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF
+ *              : and return that ordered list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.2.update.sqlpp
new file mode 100644
index 0000000..12226f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.2.update.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.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF
+ *              : and return that ordered list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.3.query.sqlpp
new file mode 100644
index 0000000..99200bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf01/udf01.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF
+ *              : and return that ordered list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+select element test.echo(a)
+from  [1,2,3,4,5,6,7,8,9,10] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.1.ddl.sqlpp
new file mode 100644
index 0000000..4019738
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.1.ddl.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.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.2.update.sqlpp
new file mode 100644
index 0000000..4019738
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.2.update.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.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.3.query.sqlpp
new file mode 100644
index 0000000..7230e45
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf02/udf02.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+select element test.getFirst(a)
+from  [[1,2],[3,4]] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.1.ddl.sqlpp
new file mode 100644
index 0000000..d5fe961
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.1.ddl.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.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ * Ignored      : Not part of test build due to Issue 200
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.2.update.sqlpp
new file mode 100644
index 0000000..d5fe961
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.2.update.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.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ * Ignored      : Not part of test build due to Issue 200
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.3.query.sqlpp
new file mode 100644
index 0000000..b0a7ec4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf03/udf03.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass an ordered list as input to UDF and return the zeroth element of that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ * Ignored      : Not part of test build due to Issue 200
+ */
+
+use test;
+
+
+select element test.echo(a)
+from  [[1,2],['A','B'],['UCLA','UCSD','UCR','UCI']] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.1.ddl.sqlpp
new file mode 100644
index 0000000..25cb292
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.1.ddl.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.
+ */
+/*
+ * Description  : Pass as input an ordered list of Records as input to UDF and return the list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.2.update.sqlpp
new file mode 100644
index 0000000..25cb292
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.2.update.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.
+ */
+/*
+ * Description  : Pass as input an ordered list of Records as input to UDF and return the list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.3.query.sqlpp
new file mode 100644
index 0000000..7b97a3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf04/udf04.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass as input an ordered list of Records as input to UDF and return the list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+select element test.echo(a)
+from  [{'name':'John','age':45,'id':123},{'name':'Jim','age':55,'id':103},{'name':'Bill','age':35,'id':125}] as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.1.ddl.sqlpp
new file mode 100644
index 0000000..abf4af3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and bind its return value to a variable and return that variable
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.2.update.sqlpp
new file mode 100644
index 0000000..abf4af3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.2.update.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.
+ */
+/*
+ * Description  : Create UDF and bind its return value to a variable and return that variable
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.3.query.sqlpp
new file mode 100644
index 0000000..7852b21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf05/udf05.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and bind its return value to a variable and return that variable
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+use test;
+
+
+test.echo(1234);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.1.ddl.sqlpp
new file mode 100644
index 0000000..befcd67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.1.ddl.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.
+ */
+/*
+ * Description  : Pass input of type double to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.2.update.sqlpp
new file mode 100644
index 0000000..befcd67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.2.update.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.
+ */
+/*
+ * Description  : Pass input of type double to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.3.query.sqlpp
new file mode 100644
index 0000000..d03c28b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf06/udf06.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass input of type double to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+test.echo(1234.1);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.1.ddl.sqlpp
new file mode 100644
index 0000000..ae66d5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.1.ddl.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.
+ */
+/*
+ * Description  : Pass value of type float to UDF
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.2.update.sqlpp
new file mode 100644
index 0000000..ae66d5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.2.update.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.
+ */
+/*
+ * Description  : Pass value of type float to UDF
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.3.query.sqlpp
new file mode 100644
index 0000000..abba8a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf07/udf07.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass value of type float to UDF
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+use test;
+
+
+test.echo(1234.099976f);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.1.ddl.sqlpp
new file mode 100644
index 0000000..36bf955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.1.ddl.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.
+ */
+/*
+ * Description  : Pass a sting as input to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.2.update.sqlpp
new file mode 100644
index 0000000..36bf955
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.2.update.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.
+ */
+/*
+ * Description  : Pass a sting as input to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.3.query.sqlpp
new file mode 100644
index 0000000..66325b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf08/udf08.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Pass a sting as input to UDF
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+test.echo('This is a test string');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.1.ddl.sqlpp
new file mode 100644
index 0000000..414d6d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to read from internal dataset
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.2.update.sqlpp
new file mode 100644
index 0000000..2fd8a28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.2.update.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * 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  : Create UDF to read from internal dataset 
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+use test;
+
+
+insert into test.t1
+select element {'id':345};
+insert into test.t1
+select element {'id':315};
+insert into test.t1
+select element {'id':245};
+insert into test.t1
+select element {'id':385};
+insert into test.t1
+select element {'id':241};
+insert into test.t1
+select element {'id':745};
+insert into test.t1
+select element {'id':349};
+insert into test.t1
+select element {'id':845};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.3.query.sqlpp
new file mode 100644
index 0000000..66e1db3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf09/udf09.3.query.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.
+ */
+/*
+ * Description  : Create UDF to read from internal dataset 
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+use test;
+
+
+select element test.readDataset((
+    select element a
+    from  "test.t1" as a
+    order by a.id
+));
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.1.ddl.sqlpp
new file mode 100644
index 0000000..aa78721
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and pass an unordered list as input and return that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.2.update.sqlpp
new file mode 100644
index 0000000..aa78721
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.2.update.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.
+ */
+/*
+ * Description  : Create UDF and pass an unordered list as input and return that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.3.query.sqlpp
new file mode 100644
index 0000000..e18625a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf10/udf10.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and pass an unordered list as input and return that list.
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+test.echo({{'this is optional data','this is extra data','open types are good'}});
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.1.ddl.sqlpp
new file mode 100644
index 0000000..9170318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to return ordered list of integers
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.2.update.sqlpp
new file mode 100644
index 0000000..9170318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.2.update.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.
+ */
+/*
+ * Description  : Create UDF to return ordered list of integers
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.3.query.sqlpp
new file mode 100644
index 0000000..bc71718
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf11/udf11.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF to return ordered list of integers
+ * Expected Res : Success
+ * Date         : Sep 4th 2012
+ */
+
+use test;
+
+
+select element a
+from  test.OList() as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.1.ddl.sqlpp
new file mode 100644
index 0000000..26f68f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to add two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.2.update.sqlpp
new file mode 100644
index 0000000..26f68f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.2.update.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.
+ */
+/*
+ * Description  : Create UDF to add two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.3.query.sqlpp
new file mode 100644
index 0000000..4c6365f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf12/udf12.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF to add two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+select element test.foo(100,200);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.1.ddl.sqlpp
new file mode 100644
index 0000000..4b35b6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to subtract two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.2.update.sqlpp
new file mode 100644
index 0000000..4b35b6c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.2.update.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.
+ */
+/*
+ * Description  : Create UDF to subtract two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.3.query.sqlpp
new file mode 100644
index 0000000..fcacad1d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf13/udf13.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF to subtract two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+select element test.foo(400,200);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.1.ddl.sqlpp
new file mode 100644
index 0000000..558cc74
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to multiply two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.2.update.sqlpp
new file mode 100644
index 0000000..558cc74
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.2.update.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.
+ */
+/*
+ * Description  : Create UDF to multiply two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.3.query.sqlpp
new file mode 100644
index 0000000..731bbfa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf14/udf14.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF to multiply two integers
+ * Expected Res : Success
+ * Date         : 4th September 2012
+ */
+
+use test;
+
+
+select element test.foo(400,200);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.1.ddl.sqlpp
new file mode 100644
index 0000000..83ecf21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF that returns a heterogeneous ordered list
+ *              : invoke the UDF in the FOR expression of FLWOR
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ * Ignored      : Not part of current tests because of Issue 200
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.2.update.sqlpp
new file mode 100644
index 0000000..83ecf21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.2.update.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.
+ */
+/*
+ * Description  : Create UDF that returns a heterogeneous ordered list
+ *              : invoke the UDF in the FOR expression of FLWOR
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ * Ignored      : Not part of current tests because of Issue 200
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.3.query.sqlpp
new file mode 100644
index 0000000..27d98c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf15/udf15.3.query.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.
+ */
+/*
+ * Description  : Create UDF that returns a heterogeneous ordered list
+ *              : invoke the UDF in the FOR expression of FLWOR
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ * Ignored      : Not part of current tests because of Issue 200
+ */
+
+use test;
+
+
+select element a
+from  test.OList2() as a
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.1.ddl.sqlpp
new file mode 100644
index 0000000..ec2336e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF that returns string
+ *              : compute the string lenght of the string
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.2.update.sqlpp
new file mode 100644
index 0000000..ec2336e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.2.update.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.
+ */
+/*
+ * Description  : Create UDF that returns string
+ *              : compute the string lenght of the string
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.3.query.sqlpp
new file mode 100644
index 0000000..48ae9da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf16/udf16.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF that returns string
+ *              : compute the string lenght of the string
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+test."string-length"(test.fn02());
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.1.ddl.sqlpp
new file mode 100644
index 0000000..c209960
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke it from another UDF and 
+ *              : child UDF returns a string to the parent.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.2.update.sqlpp
new file mode 100644
index 0000000..c209960
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke it from another UDF and 
+ *              : child UDF returns a string to the parent.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.3.query.sqlpp
new file mode 100644
index 0000000..afd98ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf17/udf17.3.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke it from another UDF and 
+ *              : child UDF returns a string to the parent.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+test.parent();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.1.ddl.sqlpp
new file mode 100644
index 0000000..9bbef2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke the UDF from with in asterix built-in function
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.2.update.sqlpp
new file mode 100644
index 0000000..9bbef2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke the UDF from with in asterix built-in function
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.3.query.sqlpp
new file mode 100644
index 0000000..1e6c0c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf18/udf18.3.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke the UDF from with in asterix built-in function
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+set "import-private-functions" "true";
+
+test.not(test.fn06());
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.1.ddl.sqlpp
new file mode 100644
index 0000000..84deb19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.2.update.sqlpp
new file mode 100644
index 0000000..84deb19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.3.query.sqlpp
new file mode 100644
index 0000000..51a6bc3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf19/udf19.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+select element test.area(a)
+from  [2,4,6,8,10,12] as a
+where (test.area(a) > 100)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.1.ddl.sqlpp
new file mode 100644
index 0000000..84deb19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.2.update.sqlpp
new file mode 100644
index 0000000..84deb19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.3.query.sqlpp
new file mode 100644
index 0000000..1d93d5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf20/udf20.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke in the WHERE clause of FLWOR expression
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+select element {'radius':a,'area':test.area(a)}
+from  [2,4,6,8,10,12] as a
+where (test.area(a) > 100)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.1.ddl.sqlpp
new file mode 100644
index 0000000..211e12c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to verify if input is odd
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.2.update.sqlpp
new file mode 100644
index 0000000..211e12c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.2.update.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.
+ */
+/*
+ * Description  : Create UDF to verify if input is odd
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.3.query.sqlpp
new file mode 100644
index 0000000..e3d8368
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf21/udf21.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF to verify if input is odd
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+select element a
+from  [10,20,2,30,4,3,6,44,5,7,9,1,13,17,992,19,40,50,60,25,45,65,75] as a
+where test.isOdd(a)
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.1.ddl.sqlpp
new file mode 100644
index 0000000..67c9c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF to concatenate two input strings.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.2.update.sqlpp
new file mode 100644
index 0000000..67c9c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.2.update.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.
+ */
+/*
+ * Description  : Create UDF to concatenate two input strings.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.3.query.sqlpp
new file mode 100644
index 0000000..68fda45
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf22/udf22.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF to concatenate two input strings.
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+test.getFullName('Bob','Harbus');
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.1.ddl.sqlpp
new file mode 100644
index 0000000..f038f5b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke it in limit clause
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.2.update.sqlpp
new file mode 100644
index 0000000..f038f5b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke it in limit clause
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.3.query.sqlpp
new file mode 100644
index 0000000..30fd561
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf23/udf23.3.query.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.
+ */
+/*
+ * Description  : Create UDF and invoke it in limit clause
+ * Expected Res : Success
+ * Date         : Sep 5th 2012
+ */
+
+use test;
+
+
+select element l
+from  "Metadata.Dataset" as l
+where (l.DataverseName = 'Metadata')
+order by l.DatasetName
+limit test.numRows()
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.1.ddl.sqlpp
new file mode 100644
index 0000000..e13a2cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF that returns a range
+ * Expected Res : Success
+ * Date         : Sep 5 2012
+ * Ignored      : Not part of current test build because of Issue 201
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.2.update.sqlpp
new file mode 100644
index 0000000..e13a2cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.2.update.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.
+ */
+/*
+ * Description  : Create UDF that returns a range
+ * Expected Res : Success
+ * Date         : Sep 5 2012
+ * Ignored      : Not part of current test build because of Issue 201
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.3.query.sqlpp
new file mode 100644
index 0000000..b869bfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf24/udf24.3.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF that returns a range
+ * Expected Res : Success
+ * Date         : Sep 5 2012
+ * Ignored      : Not part of current test build because of Issue 201
+ */
+
+use test;
+
+
+select element i
+from  test.myRangeFn(100) as i
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.1.ddl.sqlpp
new file mode 100644
index 0000000..8bce363
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke with negative inputs.
+ * Expected Res : Failure
+ * Date         : 5th Sep 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.2.update.sqlpp
new file mode 100644
index 0000000..8bce363
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke with negative inputs.
+ * Expected Res : Failure
+ * Date         : 5th Sep 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.3.query.sqlpp
new file mode 100644
index 0000000..3ff3509
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf25/udf25.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke with negative inputs.
+ * Expected Res : Failure
+ * Date         : 5th Sep 2012
+ */
+
+use test;
+
+
+select element test.computeBonus(-1,-1);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.1.ddl.sqlpp
new file mode 100644
index 0000000..62a7a0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and define with missing references.
+ * Expected Res : Failure
+ * Date         : Sep 6th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.2.update.sqlpp
new file mode 100644
index 0000000..62a7a0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.2.update.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.
+ */
+/*
+ * Description  : Create UDF and define with missing references.
+ * Expected Res : Failure
+ * Date         : Sep 6th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.3.query.sqlpp
new file mode 100644
index 0000000..161929d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf26/udf26.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and define with missing references.
+ * Expected Res : Failure
+ * Date         : Sep 6th 2012
+ */
+
+use test;
+
+
+select element test.needs_f1(12345);
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.1.ddl.sqlpp
new file mode 100644
index 0000000..4e255e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and invoke UDF from a quantified expression
+ * Expected Res : Success
+ * Date         : Sep 6th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.2.update.sqlpp
new file mode 100644
index 0000000..4e255e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.2.update.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.
+ */
+/*
+ * Description  : Create UDF and invoke UDF from a quantified expression
+ * Expected Res : Success
+ * Date         : Sep 6th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.3.query.sqlpp
new file mode 100644
index 0000000..9230553
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf27/udf27.3.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create UDF and invoke UDF from a quantified expression
+ * Expected Res : Success
+ * Date         : Sep 6th 2012
+ */
+
+use test;
+
+
+some i in [100,200] satisfies (i < test.f1());
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf28/udf28.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf28/udf28.1.ddl.sqlpp
new file mode 100644
index 0000000..eb5ed5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf28/udf28.1.ddl.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.
+ */
+/*
+ * Description  : Create UDF and terminate the statement with a ';'
+ * Expected Res : Success
+ * Date         : Sep 6th 2012
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf28/udf28.2.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf28/udf28.2.query.sqlpp
new file mode 100644
index 0000000..e2f1929
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf28/udf28.2.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Create a UDF but use ';' for terminating the create function statement. Look up metadata
+ * Expected Res : Success
+ * Date         : Apr 5th 2013
+ */
+
+use test;
+
+
+select element x
+from  "Metadata.Function" as x
+where (x.DataverseName = 'test')
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf29/udf29.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf29/udf29.1.ddl.sqlpp
new file mode 100644
index 0000000..015d4fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf29/udf29.1.ddl.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : Declare UDF and terminate the statement with a ';'
+ * Expected Res : Success
+ * Date         : Apr 10th 2013
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf29/udf29.2.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf29/udf29.2.query.sqlpp
new file mode 100644
index 0000000..f9ad71d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf29/udf29.2.query.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : Declare a UDF but use ';' for terminating the declare function statement. Invoke the function
+ * Expected Res : Success
+ * Date         : Apr 10th 2013
+ */
+
+use test;
+
+
+declare function f1() {
+100
+};
+test.f1();
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf30/udf30.1.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf30/udf30.1.query.sqlpp
new file mode 100644
index 0000000..9cf7dd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf30/udf30.1.query.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.
+ */
+/*
+ * Description  : Declare a UDF and try to use the function parameter outside
+ *                of the function.
+ * Expected Res : Failure
+ * Date         : Apr 10th 2013
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.1.ddl.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.1.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.2.update.sqlpp
new file mode 100644
index 0000000..6bc601a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.2.update.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.
+ */
+
+use emergencyTest;
+
+
+insert into EmergencyReports
+select element {'id':1,'intensity':1,'message':'emergency1'};
+insert into EmergencyReports
+select element {'id':2,'intensity':2,'message':'emergency2'};
+insert into EmergencyReports
+select element {'id':3,'intensity':3,'message':'emergency3'};
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.3.query.sqlpp
new file mode 100644
index 0000000..3e7c1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/user-defined-functions/udf31/udf31.3.query.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 emergencyTest;
+
+
+select element result
+from  emergencyTest.mostIntenseEarthquakeNearLocation() as result
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.3.query.sqlpp
new file mode 100644
index 0000000..a739f62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/print_01/print_01.3.query.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 element x
+from  ['foo','bar'] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.1.ddl.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.1.ddl.sqlpp
new file mode 100644
index 0000000..15f980b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.1.ddl.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.
+ */
+
+drop  database test if exists;
+create  database test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.2.update.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.2.update.sqlpp
new file mode 100644
index 0000000..bd244d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.2.update.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.3.query.sqlpp b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.3.query.sqlpp
new file mode 100644
index 0000000..a739f62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/writers/serialized_01/serialized_01.3.query.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 element x
+from  ['foo','bar'] as x
+;
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast
new file mode 100644
index 0000000..e8ff6f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null/agg_null.3.ast
@@ -0,0 +1,98 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count1]
+    :
+    FunctionCall null.sql-count@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average1]
+    :
+    FunctionCall null.sql-avg@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum1]
+    :
+    FunctionCall null.sql-sum@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min1]
+    :
+    FunctionCall null.sql-min@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max1]
+    :
+    FunctionCall null.sql-max@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-count2]
+    :
+    FunctionCall null.sql-count@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average2]
+    :
+    FunctionCall null.sql-avg@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum2]
+    :
+    FunctionCall null.sql-sum@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min2]
+    :
+    FunctionCall null.sql-min@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max2]
+    :
+    FunctionCall null.sql-max@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.1.ast
new file mode 100644
index 0000000..a407e0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast
new file mode 100644
index 0000000..2967c35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec/agg_null_rec.3.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count]
+    :
+    FunctionCall test.sql-count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum]
+    :
+    FunctionCall test.sql-sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min]
+    :
+    FunctionCall test.sql-min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max]
+    :
+    FunctionCall test.sql-max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.1.ast
new file mode 100644
index 0000000..a407e0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast
new file mode 100644
index 0000000..20e9b29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_null_rec_1/agg_null_rec_1.3.ast
@@ -0,0 +1,133 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count]
+    :
+    FunctionCall test.sql-count@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=t ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=val
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum]
+    :
+    FunctionCall test.sql-sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=val
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min]
+    :
+    FunctionCall test.sql-min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=valplus
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max]
+    :
+    FunctionCall test.sql-max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=valplus
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast
new file mode 100644
index 0000000..126ceba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number/agg_number.3.ast
@@ -0,0 +1,163 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count1]
+    :
+    FunctionCall null.sql-count@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average1]
+    :
+    FunctionCall null.sql-avg@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum1]
+    :
+    FunctionCall null.sql-sum@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min1]
+    :
+    FunctionCall null.sql-min@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max1]
+    :
+    FunctionCall null.sql-max@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-count2]
+    :
+    FunctionCall null.sql-count@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average2]
+    :
+    FunctionCall null.sql-avg@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum2]
+    :
+    FunctionCall null.sql-sum@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min2]
+    :
+    FunctionCall null.sql-min@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max2]
+    :
+    FunctionCall null.sql-max@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.1.ast
new file mode 100644
index 0000000..a407e0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast
new file mode 100644
index 0000000..2967c35
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/agg_number_rec/agg_number_rec.3.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count]
+    :
+    FunctionCall test.sql-count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum]
+    :
+    FunctionCall test.sql-sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min]
+    :
+    FunctionCall test.sql-min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max]
+    :
+    FunctionCall test.sql-max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.3.ast
new file mode 100644
index 0000000..534efd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double/avg_double.3.ast
@@ -0,0 +1,20 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [2.0]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.3.ast
new file mode 100644
index 0000000..c7b919e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_double_null/avg_double_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.3.ast
new file mode 100644
index 0000000..59b1670
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_01/avg_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.1.ast
new file mode 100644
index 0000000..da408d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.3.ast
new file mode 100644
index 0000000..f9887fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_empty_02/avg_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.3.ast
new file mode 100644
index 0000000..a5dd207
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float/avg_float.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.3.ast
new file mode 100644
index 0000000..4202d44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_float_null/avg_float_nu.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=floatField
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.3.ast
new file mode 100644
index 0000000..2961824
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16/avg_int16.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.3.ast
new file mode 100644
index 0000000..bf92b19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int16_null/avg_int16_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int16Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.3.ast
new file mode 100644
index 0000000..2d3def0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32/avg_int32.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.3.ast
new file mode 100644
index 0000000..918740e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int32_null/avg_int32_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int32Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.3.ast
new file mode 100644
index 0000000..3f6cc7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64/avg_int64.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.3.ast
new file mode 100644
index 0000000..74fa23c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int64_null/avg_int64_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int64Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.3.ast
new file mode 100644
index 0000000..32031da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8/avg_int8.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.3.ast
new file mode 100644
index 0000000..c3b88b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_int8_null/avg_int8_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.sql-avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int8Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast
new file mode 100644
index 0000000..c772c5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/avg_mixed/avg_mixed.3.ast
@@ -0,0 +1,23 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sql-avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.3.ast
new file mode 100644
index 0000000..f1f381b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_01/count_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.3.ast
new file mode 100644
index 0000000..1909937
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_01/count_empty_01.3.ast
@@ -0,0 +1,24 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sql-count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.1.ast
new file mode 100644
index 0000000..da408d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.3.ast
new file mode 100644
index 0000000..d8394cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_empty_02/count_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-count@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.3.ast
new file mode 100644
index 0000000..9910dff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/count_null/count_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count]
+    :
+    FunctionCall test.sql-count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.1.ast
new file mode 100644
index 0000000..9956d30
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl Emp [
+  open RecordType {
+    id : int64,
+    name : string?
+  }
+]
+DatasetDecl Employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.3.ast
new file mode 100644
index 0000000..bb48475
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue395/issue395.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-count@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=name
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Employee]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.3.ast
new file mode 100644
index 0000000..31974e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_0/issue412_0.3.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.sql-count@1[
+  OrderedListConstructor [
+    LiteralExpr [STRING] [ASTERIX]
+    LiteralExpr [STRING] [Hyracks]
+    LiteralExpr [NULL]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.3.ast
new file mode 100644
index 0000000..4c5af72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue412_1/issue412_1.3.ast
@@ -0,0 +1,58 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-count]
+    :
+    FunctionCall null.sql-count@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall null.sql-avg@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-sum]
+    :
+    FunctionCall null.sql-sum@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-min]
+    :
+    FunctionCall null.sql-min@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max]
+    :
+    FunctionCall null.sql-max@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.3.ast
new file mode 100644
index 0000000..fbe0b62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list/issue425_min_hetero_list.3.ast
@@ -0,0 +1,7 @@
+Query:
+FunctionCall null.sql-min@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [23]
+    LiteralExpr [LONG] [748374857483]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.ast
new file mode 100644
index 0000000..465ed26
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.sql-min@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [748374857483]
+    LiteralExpr [LONG] [23]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.3.ast
new file mode 100644
index 0000000..a1b6a6e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list/issue425_sum_hetero_list.3.ast
@@ -0,0 +1,7 @@
+Query:
+FunctionCall null.sql-sum@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [23]
+    LiteralExpr [LONG] [748374857483]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.ast
new file mode 100644
index 0000000..200d11c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.sql-sum@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [748374857483]
+    LiteralExpr [LONG] [23]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.1.ast
new file mode 100644
index 0000000..1b709d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    name : string
+  }
+]
+DatasetDecl t1(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.3.ast
new file mode 100644
index 0000000..3f8f2e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/issue531_string_min_max/issue531_string_min_max.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sql-min]
+    :
+    FunctionCall test.sql-min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=name
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [t1]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sql-max]
+    :
+    FunctionCall test.sql-max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=name
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [t1]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.3.ast
new file mode 100644
index 0000000..c112a3f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_01/max_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-max@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.1.ast
new file mode 100644
index 0000000..da408d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.3.ast
new file mode 100644
index 0000000..e067564
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/max_empty_02/max_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-max@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.3.ast
new file mode 100644
index 0000000..211e1c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_01/min_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-min@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.1.ast
new file mode 100644
index 0000000..da408d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.3.ast
new file mode 100644
index 0000000..9c636ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_empty_02/min_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-min@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.3.ast
new file mode 100644
index 0000000..5001cd1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/min_mixed/min_mixed.3.ast
@@ -0,0 +1,23 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sql-min@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/query-issue400/query-issue400.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.3.ast
new file mode 100644
index 0000000..2d24805
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg/scalar_avg.3.ast
@@ -0,0 +1,106 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.3.ast
new file mode 100644
index 0000000..7da8ba1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_empty/scalar_avg_empty.3.ast
@@ -0,0 +1,7 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sql-avg@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.3.ast
new file mode 100644
index 0000000..557f08b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_avg_null/scalar_avg_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-avg@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.3.ast
new file mode 100644
index 0000000..0511e9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count/scalar_count.3.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [a]
+      LiteralExpr [STRING] [b]
+      LiteralExpr [STRING] [c]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.3.ast
new file mode 100644
index 0000000..863c3a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_empty/scalar_count_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-count@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.3.ast
new file mode 100644
index 0000000..90369f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_count_null/scalar_count_null.3.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.sql-count@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [a]
+      LiteralExpr [STRING] [b]
+      LiteralExpr [STRING] [c]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.3.ast
new file mode 100644
index 0000000..0d96f9c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max/scalar_max.3.ast
@@ -0,0 +1,132 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.3.ast
new file mode 100644
index 0000000..549ce92
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_empty/scalar_max_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-max@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.3.ast
new file mode 100644
index 0000000..c108525
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_max_null/scalar_max_null.3.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.sql-max@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.3.ast
new file mode 100644
index 0000000..d817b6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min/scalar_min.3.ast
@@ -0,0 +1,132 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.3.ast
new file mode 100644
index 0000000..541c673
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_empty/scalar_min_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-min@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.3.ast
new file mode 100644
index 0000000..9eaae70
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_min_null/scalar_min_null.3.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.sql-min@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.3.ast
new file mode 100644
index 0000000..27bd715
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum/scalar_sum.3.ast
@@ -0,0 +1,106 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.3.ast
new file mode 100644
index 0000000..36b9790
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_empty/scalar_sum_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.3.ast
new file mode 100644
index 0000000..94d8dd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/scalar_sum_null/scalar_sum_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sql-sum@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.3.ast
new file mode 100644
index 0000000..3b0400a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double/sum_double.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [2.0]
+        LiteralExpr [DOUBLE] [3.0]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.3.ast
new file mode 100644
index 0000000..eb881ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_double_null/sum_double_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=doubleField
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.3.ast
new file mode 100644
index 0000000..4262dd6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_01/sum_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.1.ast
new file mode 100644
index 0000000..da408d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.3.ast
new file mode 100644
index 0000000..d0b8323
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_empty_02/sum_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.3.ast
new file mode 100644
index 0000000..9b38f1f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float/sum_float.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.3.ast
new file mode 100644
index 0000000..a97f1bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_float_null/sum_float_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=floatField
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.3.ast
new file mode 100644
index 0000000..1acd1e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16/sum_int16.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.3.ast
new file mode 100644
index 0000000..13000a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int16_null/sum_int16_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int16Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.3.ast
new file mode 100644
index 0000000..06d76c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32/sum_int32.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.3.ast
new file mode 100644
index 0000000..2d57c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int32_null/sum_int32_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int32Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.3.ast
new file mode 100644
index 0000000..7c91476
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64/sum_int64.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.3.ast
new file mode 100644
index 0000000..6bb78c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int64_null/sum_int64_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int64Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.3.ast
new file mode 100644
index 0000000..14025b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8/sum_int8.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.3.ast
new file mode 100644
index 0000000..6bb0066
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_int8_null/sum_int8_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int8Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.ast
new file mode 100644
index 0000000..3f8aff5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_mixed/sum_mixed.3.ast
@@ -0,0 +1,23 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.1.ast
new file mode 100644
index 0000000..c2f884c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    sal : int64?
+  }
+]
+DatasetDecl tdst(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.3.ast
new file mode 100644
index 0000000..0bfc9d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_null-with-pred/sum_null-with-pred.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=sal
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [tdst]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      FunctionCall test.not@1[
+        FunctionCall test.is-null@1[
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=sal
+          ]
+        ]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.1.ast
new file mode 100644
index 0000000..c2f884c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    sal : int64?
+  }
+]
+DatasetDecl tdst(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.3.ast
new file mode 100644
index 0000000..becfad0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate-sql/sum_numeric_null/sum_numeric_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sql-sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=sal
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [tdst]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast
new file mode 100644
index 0000000..bae05c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null/agg_null.3.ast
@@ -0,0 +1,98 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FunctionCall null.count@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average1]
+    :
+    FunctionCall null.avg@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum1]
+    :
+    FunctionCall null.sum@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min1]
+    :
+    FunctionCall null.min@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max1]
+    :
+    FunctionCall null.max@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count2]
+    :
+    FunctionCall null.count@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average2]
+    :
+    FunctionCall null.avg@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum2]
+    :
+    FunctionCall null.sum@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min2]
+    :
+    FunctionCall null.min@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max2]
+    :
+    FunctionCall null.max@1[
+      UnorderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.1.ast
new file mode 100644
index 0000000..8288e2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast
new file mode 100644
index 0000000..4976f97
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec/agg_null_rec.3.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum]
+    :
+    FunctionCall test.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min]
+    :
+    FunctionCall test.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max]
+    :
+    FunctionCall test.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.1.ast
new file mode 100644
index 0000000..8288e2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast
new file mode 100644
index 0000000..cae68d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_null_rec_1/agg_null_rec_1.3.ast
@@ -0,0 +1,133 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=t ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=val
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum]
+    :
+    FunctionCall test.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=val
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min]
+    :
+    FunctionCall test.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=valplus
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max]
+    :
+    FunctionCall test.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=valplus
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=t ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Test]
+              ]
+              AS
+              Variable [ Name=t ]
+            ]
+          )
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast
new file mode 100644
index 0000000..9400e91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number/agg_number.3.ast
@@ -0,0 +1,163 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FunctionCall null.count@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average1]
+    :
+    FunctionCall null.avg@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum1]
+    :
+    FunctionCall null.sum@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min1]
+    :
+    FunctionCall null.min@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max1]
+    :
+    FunctionCall null.max@1[
+      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count2]
+    :
+    FunctionCall null.count@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average2]
+    :
+    FunctionCall null.avg@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum2]
+    :
+    FunctionCall null.sum@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min2]
+    :
+    FunctionCall null.min@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max2]
+    :
+    FunctionCall null.max@1[
+      UnorderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+        LiteralExpr [LONG] [93847382783847382]
+        LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.1.ast
new file mode 100644
index 0000000..8288e2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast
new file mode 100644
index 0000000..4976f97
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/agg_number_rec/agg_number_rec.3.ast
@@ -0,0 +1,104 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum]
+    :
+    FunctionCall test.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min]
+    :
+    FunctionCall test.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max]
+    :
+    FunctionCall test.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=valplus
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Test]
+          ]
+          AS
+          Variable [ Name=t ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.3.ast
new file mode 100644
index 0000000..d979a6e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double/avg_double.3.ast
@@ -0,0 +1,20 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [2.0]
+        FunctionCall null.double@1[
+          LiteralExpr [STRING] [3.0]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.3.ast
new file mode 100644
index 0000000..b946881
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_double_null/avg_double_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.3.ast
new file mode 100644
index 0000000..236a7de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_01/avg_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.1.ast
new file mode 100644
index 0000000..a74b5cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.3.ast
new file mode 100644
index 0000000..18cf26c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_empty_02/avg_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.3.ast
new file mode 100644
index 0000000..7d9e49d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float/avg_float.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.3.ast
new file mode 100644
index 0000000..5cd105d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_float_null/avg_float_nu.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=floatField
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.3.ast
new file mode 100644
index 0000000..3421856
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16/avg_int16.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.3.ast
new file mode 100644
index 0000000..37e709a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int16_null/avg_int16_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int16Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.3.ast
new file mode 100644
index 0000000..514e8ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32/avg_int32.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.3.ast
new file mode 100644
index 0000000..7b84875
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int32_null/avg_int32_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int32Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.3.ast
new file mode 100644
index 0000000..31c9432
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64/avg_int64.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.3.ast
new file mode 100644
index 0000000..a2e73ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int64_null/avg_int64_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int64Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.3.ast
new file mode 100644
index 0000000..ad6ccba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8/avg_int8.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.3.ast
new file mode 100644
index 0000000..7a932c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_int8_null/avg_int8_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall test.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=int8Field
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.3.ast
new file mode 100644
index 0000000..23fb1f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/avg_mixed/avg_mixed.3.ast
@@ -0,0 +1,23 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.avg@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.3.ast
new file mode 100644
index 0000000..ec31659
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_01/count_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.3.ast
new file mode 100644
index 0000000..db67870
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_01/count_empty_01.3.ast
@@ -0,0 +1,24 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.1.ast
new file mode 100644
index 0000000..a74b5cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.3.ast
new file mode 100644
index 0000000..3cd5b5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_empty_02/count_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.count@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.3.ast
new file mode 100644
index 0000000..08cf114
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/count_null/count_null.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=doubleField
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Numeric]
+          ]
+          AS
+          Variable [ Name=x ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.1.ast
new file mode 100644
index 0000000..ba19f83
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl Emp [
+  open RecordType {
+    id : int32,
+    name : string?
+  }
+]
+DatasetDecl Employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.3.ast
new file mode 100644
index 0000000..2801aed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue395/issue395.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.count@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=name
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Employee]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.3.ast
new file mode 100644
index 0000000..ade42d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_0/issue412_0.3.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.count@1[
+  OrderedListConstructor [
+    LiteralExpr [STRING] [ASTERIX]
+    LiteralExpr [STRING] [Hyracks]
+    LiteralExpr [NULL]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.3.ast
new file mode 100644
index 0000000..e89f061
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue412_1/issue412_1.3.ast
@@ -0,0 +1,58 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall null.count@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [average]
+    :
+    FunctionCall null.avg@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum]
+    :
+    FunctionCall null.sum@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min]
+    :
+    FunctionCall null.min@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max]
+    :
+    FunctionCall null.max@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [60]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.ast
new file mode 100644
index 0000000..f3c68f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.ast
@@ -0,0 +1,7 @@
+Query:
+FunctionCall null.min@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [23]
+    LiteralExpr [LONG] [748374857483]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.ast
new file mode 100644
index 0000000..247d659
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.min@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [748374857483]
+    LiteralExpr [LONG] [23]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.ast
new file mode 100644
index 0000000..187b626
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.ast
@@ -0,0 +1,7 @@
+Query:
+FunctionCall null.sum@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [23]
+    LiteralExpr [LONG] [748374857483]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.ast
new file mode 100644
index 0000000..95a4b40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.ast
@@ -0,0 +1,8 @@
+Query:
+FunctionCall null.sum@1[
+  OrderedListConstructor [
+    LiteralExpr [LONG] [748374857483]
+    LiteralExpr [LONG] [23]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.1.ast
new file mode 100644
index 0000000..b80f56a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    name : string
+  }
+]
+DatasetDecl t1(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.3.ast
new file mode 100644
index 0000000..9dec63d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/issue531_string_min_max/issue531_string_min_max.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [min]
+    :
+    FunctionCall test.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=name
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [t1]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [max]
+    :
+    FunctionCall test.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=name
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [t1]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.3.ast
new file mode 100644
index 0000000..b9f1f79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_01/max_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.max@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.1.ast
new file mode 100644
index 0000000..a74b5cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.3.ast
new file mode 100644
index 0000000..1aa6529
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/max_empty_02/max_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.max@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.3.ast
new file mode 100644
index 0000000..f6a660a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_01/min_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.min@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.1.ast
new file mode 100644
index 0000000..a74b5cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.3.ast
new file mode 100644
index 0000000..5a1f7c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_empty_02/min_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.min@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.3.ast
new file mode 100644
index 0000000..8cce23d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/min_mixed/min_mixed.3.ast
@@ -0,0 +1,23 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.min@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/query-issue400/query-issue400.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.3.ast
new file mode 100644
index 0000000..21159c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg/scalar_avg.3.ast
@@ -0,0 +1,106 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.3.ast
new file mode 100644
index 0000000..19122cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_empty/scalar_avg_empty.3.ast
@@ -0,0 +1,7 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.avg@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.3.ast
new file mode 100644
index 0000000..ac89e95
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_avg_null/scalar_avg_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.avg@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.3.ast
new file mode 100644
index 0000000..08505d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count/scalar_count.3.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [a]
+      LiteralExpr [STRING] [b]
+      LiteralExpr [STRING] [c]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.3.ast
new file mode 100644
index 0000000..b283e27
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_empty/scalar_count_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.count@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.3.ast
new file mode 100644
index 0000000..2496e09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_count_null/scalar_count_null.3.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.count@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [a]
+      LiteralExpr [STRING] [b]
+      LiteralExpr [STRING] [c]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.3.ast
new file mode 100644
index 0000000..112a12d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max/scalar_max.3.ast
@@ -0,0 +1,132 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.3.ast
new file mode 100644
index 0000000..897ca40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_empty/scalar_max_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.max@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.3.ast
new file mode 100644
index 0000000..c148cee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_max_null/scalar_max_null.3.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.max@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.3.ast
new file mode 100644
index 0000000..666e43a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min/scalar_min.3.ast
@@ -0,0 +1,132 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.3.ast
new file mode 100644
index 0000000..f0b1423
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_empty/scalar_min_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.min@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.3.ast
new file mode 100644
index 0000000..a2cf93f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_min_null/scalar_min_null.3.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=s ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [foo]
+      LiteralExpr [STRING] [bar]
+      LiteralExpr [STRING] [world]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=dt ]
+  :=
+  FunctionCall test.min@1[
+    OrderedListConstructor [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-03-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-02-01T00:00:00Z]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+    Variable [ Name=s ]
+    Variable [ Name=dt ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.3.ast
new file mode 100644
index 0000000..2729c21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum/scalar_sum.3.ast
@@ -0,0 +1,106 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.3.ast
new file mode 100644
index 0000000..43d6854
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_empty/scalar_sum_empty.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  OrderedListConstructor [
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.3.ast
new file mode 100644
index 0000000..df1a452
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/scalar_sum_null/scalar_sum_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+LetVariable [ Name=i8 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i16 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i32 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=i64 ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=f ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+LetVariable [ Name=d ]
+  :=
+  FunctionCall test.sum@1[
+    OrderedListConstructor [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2]
+      ]
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=i8 ]
+    Variable [ Name=i16 ]
+    Variable [ Name=i32 ]
+    Variable [ Name=i64 ]
+    Variable [ Name=f ]
+    Variable [ Name=d ]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.3.ast
new file mode 100644
index 0000000..4b3c3cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double/sum_double.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [2.0]
+        LiteralExpr [DOUBLE] [3.0]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.3.ast
new file mode 100644
index 0000000..0972479
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_double_null/sum_double_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=doubleField
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.3.ast
new file mode 100644
index 0000000..e2f8ce7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_01/sum_empty_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+        LiteralExpr [LONG] [3]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=x ]
+        >
+        LiteralExpr [LONG] [10]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.1.ast
new file mode 100644
index 0000000..a74b5cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    val : double
+  }
+]
+DatasetDecl Test(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.3.ast
new file mode 100644
index 0000000..bb6cfc0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_empty_02/sum_empty_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=val
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Test]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.3.ast
new file mode 100644
index 0000000..bc473b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float/sum_float.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.float@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.3.ast
new file mode 100644
index 0000000..a2649d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_float_null/sum_float_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=floatField
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.3.ast
new file mode 100644
index 0000000..38c2666
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16/sum_int16.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int16@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.3.ast
new file mode 100644
index 0000000..523dcfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int16_null/sum_int16_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int16Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.3.ast
new file mode 100644
index 0000000..d2a5e9c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32/sum_int32.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int32@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.3.ast
new file mode 100644
index 0000000..59d3409
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int32_null/sum_int32_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int32Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.3.ast
new file mode 100644
index 0000000..081d221
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64/sum_int64.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int64@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.3.ast
new file mode 100644
index 0000000..91ca34d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int64_null/sum_int64_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int64Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.3.ast
new file mode 100644
index 0000000..253f544
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8/sum_int8.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [1]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [2]
+        ]
+        FunctionCall test.int8@1[
+          LiteralExpr [STRING] [3]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.1.ast
new file mode 100644
index 0000000..9e55597
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int32,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.3.ast
new file mode 100644
index 0000000..225e565
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_int8_null/sum_int8_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=int8Field
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Numeric]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.3.ast
new file mode 100644
index 0000000..6bce314
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_mixed/sum_mixed.3.ast
@@ -0,0 +1,23 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.sum@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=x ]
+    ]
+    FROM [      OrderedListConstructor [
+        FunctionCall null.float@1[
+          LiteralExpr [STRING] [2.0]
+        ]
+        LiteralExpr [STRING] [hello world]
+        LiteralExpr [LONG] [93847382783847382]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.1.ast
new file mode 100644
index 0000000..c2f884c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    sal : int64?
+  }
+]
+DatasetDecl tdst(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.3.ast
new file mode 100644
index 0000000..b478771
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_null-with-pred/sum_null-with-pred.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=sal
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [tdst]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      FunctionCall test.not@1[
+        FunctionCall test.is-null@1[
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=sal
+          ]
+        ]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.1.ast
new file mode 100644
index 0000000..9f4e952
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    sal : int32?
+  }
+]
+DatasetDecl tdst(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.3.ast
new file mode 100644
index 0000000..eadfd99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/aggregate/sum_numeric_null/sum_numeric_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.sum@1[
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=sal
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [tdst]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby-2/big_object_groupby.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_groupby/big_object_groupby.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_join/big_object_join.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/big-object/big_object_sort/big_object_sort.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.3.ast
new file mode 100644
index 0000000..b481603
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/concat/concat_01.3.ast
@@ -0,0 +1,68 @@
+DataverseUse test
+Query:
+OrderedListConstructor [
+  OperatorExpr [
+    FunctionCall test.binary-concat@1[
+      OrderedListConstructor [
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [259911]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [bb]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [31]
+        ]
+      ]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [AA259911bb31]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.binary-concat@1[
+      OrderedListConstructor [
+      ]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] []
+    ]
+  ]
+  FunctionCall test.binary-concat@1[
+    OrderedListConstructor [
+      LiteralExpr [NULL]
+    ]
+  ]
+  FunctionCall test.binary-concat@1[
+    OrderedListConstructor [
+      LiteralExpr [NULL]
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [55]
+      ]
+    ]
+  ]
+  FunctionCall test.binary-concat@1[
+    OrderedListConstructor [
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aa]
+      ]
+      LiteralExpr [NULL]
+    ]
+  ]
+  FunctionCall test.binary-concat@1[
+    OrderedListConstructor [
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aa]
+      ]
+      LiteralExpr [NULL]
+      FunctionCall test.base64@1[
+        LiteralExpr [STRING] [asdf]
+      ]
+    ]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.1.ast
new file mode 100644
index 0000000..243bb1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.1.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+TypeDecl UserType [
+  closed RecordType {
+    id : int64,
+    name : string,
+    md5 : binary
+  }
+]
+DatasetDecl User(UserType) partitioned by [[id]]
+DatasetDecl UserCopy(UserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.3.ast
new file mode 100644
index 0000000..717a2f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/equal_join/equal_join.3.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cid]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [oid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [UserCopy]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=md5
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=md5
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast
new file mode 100644
index 0000000..d7a8788
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast
@@ -0,0 +1,121 @@
+DataverseUse test
+Query:
+OrderedListConstructor [
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.find-binary@2[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] []
+        ]
+      ]
+      =
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.find-binary@2[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aa]
+        ]
+      ]
+      =
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.find-binary@3[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aa]
+        ]
+        LiteralExpr [LONG] [1]
+      ]
+      =
+      LiteralExpr [LONG] [5]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.find-binary@3[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabb]
+        ]
+        LiteralExpr [LONG] [0]
+      ]
+      =
+      FunctionCall test.find-binary@2[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabb]
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.find-binary@2[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [11]
+        ]
+      ]
+      =
+      LiteralExpr [LONG] [0]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.find-binary@2[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [ccddaa]
+        ]
+      ]
+      =
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.find-binary@2[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccddaa]
+        ]
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [ccddaabb]
+        ]
+      ]
+      =
+      LiteralExpr [LONG] [0]
+    ]
+  ]
+  FunctionCall test.find-binary@2[
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [aabbccddaa]
+    ]
+    LiteralExpr [NULL]
+  ]
+  FunctionCall test.find-binary@2[
+    LiteralExpr [NULL]
+    LiteralExpr [NULL]
+  ]
+  FunctionCall test.find-binary@2[
+    LiteralExpr [NULL]
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [aabbccddaa]
+    ]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.1.ast
new file mode 100644
index 0000000..96c8ae2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.1.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+TypeDecl UserType [
+  closed RecordType {
+    id : int64,
+    name : string,
+    md5 : binary
+  }
+]
+DatasetDecl User(UserType) partitioned by [[md5]]
+DatasetDecl UserCopy(UserType) partitioned by [[md5]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.3.ast
new file mode 100644
index 0000000..717a2f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/index_join/index_join.3.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cid]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [oid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [UserCopy]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=md5
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=md5
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.1.ast
new file mode 100644
index 0000000..24e7402
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl UserTypeOpen [
+  open RecordType {
+    id : int64
+  }
+]
+TypeDecl UserTypeClose [
+  closed RecordType {
+    id : int64,
+    name : string,
+    md5 : binary
+  }
+]
+DatasetDecl UserOpen(UserTypeOpen) partitioned by [[id]]
+DatasetDecl UserCopyClose(UserTypeClose) partitioned by [[md5]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.3.ast
new file mode 100644
index 0000000..20ea1c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/insert/insert.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [UserOpen]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=md5
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.3.ast
new file mode 100644
index 0000000..8942f96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/length/length.3.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.binary-length@1[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [00AA]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.binary-length@1[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] []
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.binary-length@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.3.ast
new file mode 100644
index 0000000..5613753
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/parse/parse.3.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+OrderedListConstructor [
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [ABCDEF0123456789]
+    LiteralExpr [STRING] [hex]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [abcdef0123456789]
+    LiteralExpr [STRING] [HEX]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [0A0B0C0D0E0F]
+    LiteralExpr [STRING] [hEx]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [01020304050607080900]
+    LiteralExpr [STRING] [hex]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] []
+    LiteralExpr [STRING] [hex]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM+/]
+    LiteralExpr [STRING] [base64]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] []
+    LiteralExpr [STRING] [base64]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [QXN0ZXJpeA==]
+    LiteralExpr [STRING] [BASE64]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [QXN0ZXJpeAE=]
+    LiteralExpr [STRING] [baSE64]
+  ]
+  FunctionCall test.parse-binary@2[
+    LiteralExpr [STRING] [QXN0ZXJpeAE8]
+    LiteralExpr [STRING] [base64]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.3.ast
new file mode 100644
index 0000000..1b58b54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/print/print.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [hex]
+    :
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FunctionCall test.print-binary@2[
+          FunctionCall test.parse-binary@2[
+            Variable [ Name=i ]
+            LiteralExpr [STRING] [hex]
+          ]
+          LiteralExpr [STRING] [hex]
+        ]
+        =
+        Variable [ Name=i ]
+      ]
+      ]
+      FROM [        OrderedListConstructor [
+          LiteralExpr [STRING] [ABCDEF0123456789]
+          LiteralExpr [STRING] [0A0B0C0D0E0F]
+          LiteralExpr [STRING] [01020304050607080900]
+          LiteralExpr [STRING] []
+        ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  )
+  (
+    LiteralExpr [STRING] [base64]
+    :
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FunctionCall test.print-binary@2[
+          FunctionCall test.parse-binary@2[
+            Variable [ Name=j ]
+            LiteralExpr [STRING] [base64]
+          ]
+          LiteralExpr [STRING] [base64]
+        ]
+        =
+        Variable [ Name=j ]
+      ]
+      ]
+      FROM [        OrderedListConstructor [
+          LiteralExpr [STRING] [0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM+/]
+          LiteralExpr [STRING] [QXN0ZXJpeA==]
+          LiteralExpr [STRING] [QXN0ZXJpeAE=]
+          LiteralExpr [STRING] [QXN0ZXJpeAE8]
+        ]
+        AS
+        Variable [ Name=j ]
+      ]
+    )
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast
new file mode 100644
index 0000000..af550bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast
@@ -0,0 +1,197 @@
+DataverseUse test
+Query:
+OperatorExpr [
+  OperatorExpr [
+    FunctionCall test.sub-binary@2[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] []
+      ]
+      LiteralExpr [LONG] [0]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] []
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@2[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] []
+      ]
+      LiteralExpr [LONG] [1]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] []
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@2[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] []
+      ]
+      NEGATIVE LiteralExpr [LONG] [1]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] []
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [1]
+      FunctionCall test.binary-length@1[
+        FunctionCall test.hex@1[
+          LiteralExpr [STRING] [aabbccdd]
+        ]
+      ]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [aabbccdd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [1]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [bb]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@2[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [bbccdd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [5]
+      LiteralExpr [LONG] [0]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] []
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [4]
+      LiteralExpr [LONG] [1]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [dd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [2]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [bbcc]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@2[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [0]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [aabbccdd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@2[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      NEGATIVE LiteralExpr [LONG] [1]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [aabbccdd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [256]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [aabbccdd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [256]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [bbccdd]
+    ]
+  ]
+  and
+  OperatorExpr [
+    FunctionCall test.sub-binary@3[
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [aabbccdd]
+      ]
+      LiteralExpr [LONG] [2]
+      NEGATIVE LiteralExpr [LONG] [1]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] []
+    ]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.3.ast
new file mode 100644
index 0000000..6146ab9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_01/and_01.3.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OperatorExpr [
+  Variable [ Name=x ]
+  and
+  Variable [ Name=y ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [true]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  OrderedListConstructor [
+    LiteralExpr [STRING] [false]
+  ]
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.3.ast
new file mode 100644
index 0000000..879fec1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null/and_null.3.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+Query:
+OperatorExpr [
+  LiteralExpr [TRUE]
+  and
+  LiteralExpr [NULL]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.3.ast
new file mode 100644
index 0000000..3f63c5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/and_null_false/and_null_false.3.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+Query:
+OperatorExpr [
+  LiteralExpr [FALSE]
+  and
+  LiteralExpr [NULL]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.3.ast
new file mode 100644
index 0000000..94a3893
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/boolean/not_01/not_01.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [not_x]
+    :
+    FunctionCall test.not@1[
+      LiteralExpr [TRUE]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [not_y]
+    :
+    FunctionCall test.not@1[
+      LiteralExpr [FALSE]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [not_z]
+    :
+    FunctionCall test.not@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.3.ast
new file mode 100644
index 0000000..854f0ba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary/binary.3.ast
@@ -0,0 +1,148 @@
+DataverseUse test
+Query:
+OrderedListConstructor [
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    >
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    >=
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    <
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    <=
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    =
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    !=
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+    >
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+    >=
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+    <
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+    <=
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+    =
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+    !=
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    =
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+    =
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0A0A]
+    ]
+    =
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cw==]
+    ]
+  ]
+  OperatorExpr [
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [0B]
+    ]
+    =
+    FunctionCall test.base64@1[
+      LiteralExpr [STRING] [Cgo=]
+    ]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.3.ast
new file mode 100644
index 0000000..3dae925
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/binary_null/binary_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [AA]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [AA]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [AA]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [AA]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [AA]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall test.hex@1[
+        LiteralExpr [STRING] [AA]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.3.ast
new file mode 100644
index 0000000..e9ab49f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_order/datetime_order.3.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+Query:
+LetVariable [ Name=dt1 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2011-12-31T14:00:00-10:00]
+  ]
+LetVariable [ Name=dt2 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+  ]
+LetVariable [ Name=dt3 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2005-01-01T00:00:00+04:00]
+  ]
+LetVariable [ Name=dt4 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2011-12-31T13:00:00-11:00]
+  ]
+LetVariable [ Name=dt5 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2012-04-06T00:00:00Z]
+  ]
+LetVariable [ Name=dt6 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [-1937-07-07T23:00:00+08:00]
+  ]
+LetVariable [ Name=dt7 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [-1600-03-01T00:00:00.384+06:00]
+  ]
+LetVariable [ Name=dt8 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [-1600-02-29T23:59:59.999Z]
+  ]
+LetVariable [ Name=dt9 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2000-02-29T23:59:59.999Z]
+  ]
+LetVariable [ Name=dt10 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [2000-03-01T01:59:59.999+07:00]
+  ]
+LetVariable [ Name=dt11 ]
+  :=
+  FunctionCall test.datetime@1[
+    LiteralExpr [STRING] [-1600-03-01T00:00:00.384-06:00]
+  ]
+SELECT ELEMENT [
+Variable [ Name=dt ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=dt1 ]
+    Variable [ Name=dt2 ]
+    Variable [ Name=dt3 ]
+    Variable [ Name=dt4 ]
+    Variable [ Name=dt5 ]
+    Variable [ Name=dt6 ]
+    Variable [ Name=dt7 ]
+    Variable [ Name=dt8 ]
+    Variable [ Name=dt9 ]
+    Variable [ Name=dt10 ]
+    Variable [ Name=dt11 ]
+  ]
+  AS
+  Variable [ Name=dt ]
+]
+Orderby
+  Variable [ Name=dt ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.1.ast
new file mode 100644
index 0000000..2559edc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl Tweet [
+  closed RecordType {
+    id : int64,
+    tweetid : int64,
+    loc : point,
+    time : datetime,
+    text : string
+  }
+]
+DatasetDecl TwitterData(Tweet) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.3.ast
new file mode 100644
index 0000000..246b7dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_range/datetime_range.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterData]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=time
+      ]
+      >
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-05-15T16:00:00Z]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-05-15T21:59:59Z]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.3.ast
new file mode 100644
index 0000000..2cef895
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/datetime_tzeq/datetime_tzeq.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-12-31T14:00:00-10:00]
+      ]
+      =
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-01-01T00:00:00Z]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2000-03-01T02:00:00+04:00]
+      ]
+      =
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2000-02-29T22:00:00Z]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.3.ast
new file mode 100644
index 0000000..2cea57c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double/double.3.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      >
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      <
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      <=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      =
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.3.ast
new file mode 100644
index 0000000..37e5558
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_gte_01/double_gte_01.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [DOUBLE] [0.8]
+    LiteralExpr [DOUBLE] [0.8999999761581421]
+    LiteralExpr [DOUBLE] [0.9]
+    LiteralExpr [DOUBLE] [0.901]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=i ]
+    >=
+    LiteralExpr [DOUBLE] [0.9]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.3.ast
new file mode 100644
index 0000000..346f8f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/double_null/double_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.3.ast
new file mode 100644
index 0000000..6220330
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/eq_01/eq_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    =
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.3.ast
new file mode 100644
index 0000000..4e4c32a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float/float.3.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      >
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      <
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      <=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      =
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.3.ast
new file mode 100644
index 0000000..4cc0876
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/float_null/float_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.3.ast
new file mode 100644
index 0000000..1dfc291
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gt_01/gt_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    >
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.3.ast
new file mode 100644
index 0000000..141f1b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/gte_01/gte_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    >=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.3.ast
new file mode 100644
index 0000000..d13d5f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16/int16.3.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      >
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      <
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      <=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      =
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.3.ast
new file mode 100644
index 0000000..30c32d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int16_null/int16_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.3.ast
new file mode 100644
index 0000000..5be4493
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32/int32.3.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      >
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      <
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      <=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      =
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.3.ast
new file mode 100644
index 0000000..82f94f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int32_null/int32_null.3.ast
@@ -0,0 +1,111 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.3.ast
new file mode 100644
index 0000000..d6bf81b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64/int64.3.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      >
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      <=
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      <
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      =
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.3.ast
new file mode 100644
index 0000000..d599378
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int64_null/int64_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.3.ast
new file mode 100644
index 0000000..1580aee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8/int8.3.ast
@@ -0,0 +1,82 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      >
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      >=
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      <
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      <=
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      =
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      !=
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.3.ast
new file mode 100644
index 0000000..671e5e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/int8_null/int8_null.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [3]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.3.ast
new file mode 100644
index 0000000..a25e02e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_equality/issue363_equality.3.ast
@@ -0,0 +1,257 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [duration]
+    :
+    OperatorExpr [
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+      =
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year-month-duration]
+    :
+    OperatorExpr [
+      FunctionCall null.year-month-duration@1[
+        LiteralExpr [STRING] [P3Y6M]
+      ]
+      =
+      FunctionCall null.year-month-duration@1[
+        LiteralExpr [STRING] [P3Y6M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day-time-duration]
+    :
+    OperatorExpr [
+      FunctionCall null.day-time-duration@1[
+        LiteralExpr [STRING] [P3DT9H5M2.348S]
+      ]
+      =
+      FunctionCall null.day-time-duration@1[
+        LiteralExpr [STRING] [P3DT9H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point]
+    :
+    OperatorExpr [
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+      =
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line]
+    :
+    OperatorExpr [
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+      =
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon]
+    :
+    OperatorExpr [
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+      =
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle]
+    :
+    OperatorExpr [
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+      =
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle]
+    :
+    OperatorExpr [
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+      =
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval]
+    :
+    OperatorExpr [
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+      =
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration2]
+    :
+    OperatorExpr [
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+      !=
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P4Y6M3DT9H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year-month-duration2]
+    :
+    OperatorExpr [
+      FunctionCall null.year-month-duration@1[
+        LiteralExpr [STRING] [P3Y6M]
+      ]
+      !=
+      FunctionCall null.year-month-duration@1[
+        LiteralExpr [STRING] [P3Y7M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day-time-duration2]
+    :
+    OperatorExpr [
+      FunctionCall null.day-time-duration@1[
+        LiteralExpr [STRING] [P3DT9H5M2.348S]
+      ]
+      !=
+      FunctionCall null.day-time-duration@1[
+        LiteralExpr [STRING] [P3DT1H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point2]
+    :
+    OperatorExpr [
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+      !=
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.4444,80.65]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line2]
+    :
+    OperatorExpr [
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+      !=
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.5678,11.1e-1 +10.2E-2,-11.22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon2]
+    :
+    OperatorExpr [
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+      !=
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle2]
+    :
+    OperatorExpr [
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+      !=
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 +10.5E-2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle2]
+    :
+    OperatorExpr [
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+      !=
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 5.5487,0.48765]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval2]
+    :
+    OperatorExpr [
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+      !=
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1983-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.3.ast
new file mode 100644
index 0000000..968e627
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_circle/issue363_inequality_circle.3.ast
@@ -0,0 +1,55 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [circle0]
+    :
+    OperatorExpr [
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+      >
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 +10.5E-2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle1]
+    :
+    OperatorExpr [
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 +10.5E-2]
+      ]
+      <
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle2]
+    :
+    OperatorExpr [
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+      >=
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 +10.5E-2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle3]
+    :
+    OperatorExpr [
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 +10.5E-2]
+      ]
+      <=
+      FunctionCall null.circle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.3.ast
new file mode 100644
index 0000000..49251c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_duration/issue363_inequality_duration.3.ast
@@ -0,0 +1,55 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [duration0]
+    :
+    OperatorExpr [
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P300Y6M3DT9H5M2.348S]
+      ]
+      >
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration1]
+    :
+    OperatorExpr [
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+      <
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P300Y6M3DT9H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration2]
+    :
+    OperatorExpr [
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P300Y6M3DT9H5M2.348S]
+      ]
+      >=
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration3]
+    :
+    OperatorExpr [
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P3Y6M3DT9H5M2.348S]
+      ]
+      <=
+      FunctionCall null.duration@1[
+        LiteralExpr [STRING] [P300Y6M3DT9H5M2.348S]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.3.ast
new file mode 100644
index 0000000..498aa79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_interval/issue363_inequality_interval.3.ast
@@ -0,0 +1,95 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [interval0]
+    :
+    OperatorExpr [
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+      >
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1983-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval1]
+    :
+    OperatorExpr [
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1983-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+      <
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval2]
+    :
+    OperatorExpr [
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+      >=
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1983-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval3]
+    :
+    OperatorExpr [
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1983-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+      <=
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [19991112T124935948-0700]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.3.ast
new file mode 100644
index 0000000..12ca8bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_line/issue363_inequality_line.3.ast
@@ -0,0 +1,55 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [line0]
+    :
+    OperatorExpr [
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+      >
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line1]
+    :
+    OperatorExpr [
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+      <
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line2]
+    :
+    OperatorExpr [
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+      >=
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line3]
+    :
+    OperatorExpr [
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+      <=
+      FunctionCall null.line@1[
+        LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.3.ast
new file mode 100644
index 0000000..23b6cbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_point/issue363_inequality_point.3.ast
@@ -0,0 +1,55 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [point0]
+    :
+    OperatorExpr [
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+      >
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.4444,80.65]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point1]
+    :
+    OperatorExpr [
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.4444,80.65]
+      ]
+      <
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point2]
+    :
+    OperatorExpr [
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+      >=
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.4444,80.65]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point3]
+    :
+    OperatorExpr [
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.4444,80.65]
+      ]
+      <=
+      FunctionCall null.point@1[
+        LiteralExpr [STRING] [47.44,80.65]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.ast
new file mode 100644
index 0000000..6bf50b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_polygon/issue363_inequality_polygon.3.ast
@@ -0,0 +1,55 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [polygon0]
+    :
+    OperatorExpr [
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+      >
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon1]
+    :
+    OperatorExpr [
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+      <
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon2]
+    :
+    OperatorExpr [
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+      >=
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon3]
+    :
+    OperatorExpr [
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.19E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+      <=
+      FunctionCall null.polygon@1[
+        LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.ast
new file mode 100644
index 0000000..ba93efa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/issue363_inequality_rectangle/issue363_inequality_rectangle.3.ast
@@ -0,0 +1,55 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [rectangle0]
+    :
+    OperatorExpr [
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+      >
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 5.5487,0.48765]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle1]
+    :
+    OperatorExpr [
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 5.5487,0.48765]
+      ]
+      <
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle2]
+    :
+    OperatorExpr [
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+      >=
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 5.5487,0.48765]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle3]
+    :
+    OperatorExpr [
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.5678,-1.00e-10 5.5487,0.48765]
+      ]
+      <=
+      FunctionCall null.rectangle@1[
+        LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.3.ast
new file mode 100644
index 0000000..9b13c70
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lt_01/lt_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    <
+    LiteralExpr [LONG] [3]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.3.ast
new file mode 100644
index 0000000..37ea949
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/lte_01/lte_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    <=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.3.ast
new file mode 100644
index 0000000..ebfd090
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/neq_01/neq_01.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=x ]
+    !=
+    LiteralExpr [LONG] [2]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.3.ast
new file mode 100644
index 0000000..fedc05d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string/string.3.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      >
+      LiteralExpr [STRING] [B]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      >=
+      LiteralExpr [STRING] [B]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      <
+      LiteralExpr [STRING] [B]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      <=
+      LiteralExpr [STRING] [B]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      =
+      LiteralExpr [STRING] [B]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      !=
+      LiteralExpr [STRING] [B]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.3.ast
new file mode 100644
index 0000000..b4b5079
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/string_null/string_null.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      >
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      >=
+      LiteralExpr [STRING] [AA]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      <
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      <=
+      LiteralExpr [STRING] [AA]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      LiteralExpr [STRING] [AA]
+      =
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+      !=
+      LiteralExpr [STRING] [AA]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.3.ast
new file mode 100644
index 0000000..b04a755
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/comparison/year_month_duration_order/year_month_duration_order.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+LetVariable [ Name=dr1 ]
+  :=
+  FunctionCall test.year-month-duration@1[
+    LiteralExpr [STRING] [P439Y]
+  ]
+LetVariable [ Name=dr2 ]
+  :=
+  FunctionCall test.year-month-duration@1[
+    LiteralExpr [STRING] [-P328M]
+  ]
+LetVariable [ Name=dr3 ]
+  :=
+  FunctionCall test.year-month-duration@1[
+    LiteralExpr [STRING] [-P48Y12M]
+  ]
+LetVariable [ Name=dr4 ]
+  :=
+  FunctionCall test.year-month-duration@1[
+    LiteralExpr [STRING] [P12M]
+  ]
+SELECT ELEMENT [
+Variable [ Name=dr ]
+]
+FROM [  OrderedListConstructor [
+    Variable [ Name=dr1 ]
+    Variable [ Name=dr2 ]
+    Variable [ Name=dr3 ]
+    Variable [ Name=dr4 ]
+  ]
+  AS
+  Variable [ Name=dr ]
+]
+Orderby
+  Variable [ Name=dr ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.3.ast
new file mode 100644
index 0000000..f2f2aa7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/add-null/add-null.3.ast
@@ -0,0 +1,10 @@
+Query:
+OperatorExpr [
+  LiteralExpr [LONG] [1]
+  +
+  LiteralExpr [LONG] [10]
+  +
+  LiteralExpr [LONG] [20]
+  +
+  LiteralExpr [NULL]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.3.ast
new file mode 100644
index 0000000..45f8b2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/binary_01/binary_01.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+OrderedListConstructor [
+  FunctionCall test.hex@1[
+    LiteralExpr [STRING] [ABCDEF0123456789]
+  ]
+  FunctionCall test.hex@1[
+    LiteralExpr [STRING] [abcdef0123456789]
+  ]
+  FunctionCall test.hex@1[
+    LiteralExpr [STRING] [0A0B0C0D0E0F]
+  ]
+  FunctionCall test.hex@1[
+    LiteralExpr [STRING] [01020304050607080900]
+  ]
+  FunctionCall test.hex@1[
+    LiteralExpr [STRING] []
+  ]
+  FunctionCall test.base64@1[
+    LiteralExpr [STRING] [0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM+/]
+  ]
+  FunctionCall test.base64@1[
+    LiteralExpr [STRING] []
+  ]
+  FunctionCall test.base64@1[
+    LiteralExpr [STRING] [QXN0ZXJpeA==]
+  ]
+  FunctionCall test.base64@1[
+    LiteralExpr [STRING] [QXN0ZXJpeAE=]
+  ]
+  FunctionCall test.base64@1[
+    LiteralExpr [STRING] [QXN0ZXJpeAE8]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.3.ast
new file mode 100644
index 0000000..300b114
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/boolean_01/boolean_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [boolean1]
+    :
+    FunctionCall test.boolean@1[
+      LiteralExpr [STRING] [true]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [boolean2]
+    :
+    FunctionCall test.boolean@1[
+      LiteralExpr [STRING] [false]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.3.ast
new file mode 100644
index 0000000..c4b1b6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/circle_01/circle_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [circle1]
+    :
+    FunctionCall test.circle@1[
+      LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle2]
+    :
+    FunctionCall test.circle@1[
+      LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.3.ast
new file mode 100644
index 0000000..94e80ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/date_01/date_01.3.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [date1]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [2010-10-30]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date2]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [1987-11-19]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date3]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [-1987-11-19]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date4]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [0001-12-27]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date5]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [-1951-12-27]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date6]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [-2043-11-19]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date7]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [-19280329]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date8]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [19280329]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date9]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [19000228]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date10]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [20000229]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast
new file mode 100644
index 0000000..db8570f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [datetime1]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [2010-10-30T10:50:56.999+05:45]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime2]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [2010-10-30T10:30:56.250-10:00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime3]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [1987-11-19T09:20:00.200Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime4]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [1987-11-19T10:50:56Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime5]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-1987-11-19T10:50:56.099-05:30]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime6]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-0001-11-19T10:50:56.719Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime7]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [1951-12-27T12:20:15Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime8]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [2043-11-19T10:50:56.719Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime9]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-19280329T174937374-0630]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime10]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-19280329T174937374+0630]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime11]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-19280329T174937374]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime12]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-19280329T174937374+0630]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime13]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-19280329T17493737+0630]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime14]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-19280301T05493737+0630]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.3.ast
new file mode 100644
index 0000000..f361f74
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/double_01/double_01.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [double1]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [NaN]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double2]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [INF]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double3]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [-INF]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double4]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [-80.20d]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double5]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [-20.56e-30]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double6]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [-20.56e-300]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.3.ast
new file mode 100644
index 0000000..abb9671
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_01/duration_01.3.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [duration1]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [P30Y10M25DT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration2]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [P25DT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration3]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [PT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration4]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [P30YT12MS]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration5]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [PT13H]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration6]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [-P30Y10M25DT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration7]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [-P25DT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration8]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [-PT13H50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration9]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [P120D]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration10]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [-P28M]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration11]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [PT29M90.937S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration12]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [P300Y15M60DT300H98M482.435S]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.3.ast
new file mode 100644
index 0000000..d34f2a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/duration_02/duration_02.3.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [duration1]
+    :
+    FunctionCall test.year-month-duration@1[
+      LiteralExpr [STRING] [P30Y10M]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration2]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [P25DT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration3]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [PT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration4]
+    :
+    FunctionCall test.year-month-duration@1[
+      LiteralExpr [STRING] [P30Y]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration5]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [PT13H]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration6]
+    :
+    FunctionCall test.year-month-duration@1[
+      LiteralExpr [STRING] [-P30Y10M]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration7]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [-P25DT13H12M50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration8]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [-PT13H50S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration9]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [P120D]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration10]
+    :
+    FunctionCall test.year-month-duration@1[
+      LiteralExpr [STRING] [-P28M]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration11]
+    :
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [PT29M90.937S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration12]
+    :
+    FunctionCall test.year-month-duration@1[
+      LiteralExpr [STRING] [P300Y15M]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.3.ast
new file mode 100644
index 0000000..58edf1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/float_01/float_01.3.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [float1]
+    :
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [NaN]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float2]
+    :
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [INF]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float3]
+    :
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [-INF]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float4]
+    :
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [-80.20]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float5]
+    :
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [-20.56e-30]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.3.ast
new file mode 100644
index 0000000..745fbbe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/int_01/int_01.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [int8]
+    :
+    FunctionCall test.int8@1[
+      LiteralExpr [STRING] [+80i8]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int16]
+    :
+    FunctionCall test.int16@1[
+      LiteralExpr [STRING] [160]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int32]
+    :
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [+320i32]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int64]
+    :
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [640]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int8_2]
+    :
+    FunctionCall test.int8@1[
+      LiteralExpr [STRING] [-80]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int16_2]
+    :
+    FunctionCall test.int16@1[
+      LiteralExpr [STRING] [-160i16]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int32_2]
+    :
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [-320]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int64_2]
+    :
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [-640i64]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int64_min]
+    :
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [-9223372036854775808]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.3.ast
new file mode 100644
index 0000000..fd0e9c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/interval/interval.3.ast
@@ -0,0 +1,360 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [interval11]
+    :
+    FunctionCall test.interval-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval12]
+    :
+    FunctionCall test.interval-from-date@2[
+      LiteralExpr [STRING] [2010-10-30]
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval13]
+    :
+    FunctionCall test.interval-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+      LiteralExpr [STRING] [2012-10-21]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval14]
+    :
+    FunctionCall test.interval-from-date@2[
+      LiteralExpr [STRING] [2010-10-30]
+      LiteralExpr [STRING] [2012-10-21]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval15]
+    :
+    FunctionCall test.interval-from-date@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [2012-10-21]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval16]
+    :
+    FunctionCall test.interval-from-date@2[
+      LiteralExpr [STRING] [2010-10-30]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval21]
+    :
+    FunctionCall test.interval-from-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [03:04:05.678-11:00]
+      ]
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [232425267+0200]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval22]
+    :
+    FunctionCall test.interval-from-time@2[
+      LiteralExpr [STRING] [03:04:05.678-11:00]
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [232425267+0200]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval23]
+    :
+    FunctionCall test.interval-from-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [03:04:05.678-11:00]
+      ]
+      LiteralExpr [STRING] [232425267+0200]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval24]
+    :
+    FunctionCall test.interval-from-time@2[
+      LiteralExpr [STRING] [03:04:05.678-11:00]
+      LiteralExpr [STRING] [232425267+0200]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval25]
+    :
+    FunctionCall test.interval-from-time@2[
+      LiteralExpr [NULL]
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [232425267+0200]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval26]
+    :
+    FunctionCall test.interval-from-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [03:04:05.678-11:00]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval31]
+    :
+    FunctionCall test.interval-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19991112T124935948-0700]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval32]
+    :
+    FunctionCall test.interval-from-datetime@2[
+      LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19991112T124935948-0700]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval33]
+    :
+    FunctionCall test.interval-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+      ]
+      LiteralExpr [STRING] [19991112T124935948-0700]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval34]
+    :
+    FunctionCall test.interval-from-datetime@2[
+      LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+      LiteralExpr [STRING] [19991112T124935948-0700]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval35]
+    :
+    FunctionCall test.interval-from-datetime@2[
+      LiteralExpr [NULL]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19991112T124935948-0700]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval36]
+    :
+    FunctionCall test.interval-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1987-11-19T02:43:57.938+08:00]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval41]
+    :
+    FunctionCall test.interval-start-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [0001-12-27]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y394DT48H398.483S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval42]
+    :
+    FunctionCall test.interval-start-from-date@2[
+      LiteralExpr [STRING] [0001-12-27]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y394DT48H398.483S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval43]
+    :
+    FunctionCall test.interval-start-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [0001-12-27]
+      ]
+      LiteralExpr [STRING] [P3Y394DT48H398.483S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval44]
+    :
+    FunctionCall test.interval-start-from-date@2[
+      LiteralExpr [STRING] [0001-12-27]
+      LiteralExpr [STRING] [P3Y394DT48H398.483S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval45]
+    :
+    FunctionCall test.interval-start-from-date@2[
+      LiteralExpr [NULL]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y394DT48H398.483S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval46]
+    :
+    FunctionCall test.interval-start-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [0001-12-27]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval51]
+    :
+    FunctionCall test.interval-start-from-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [20:03:20.948]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P60DT48M389.938S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval52]
+    :
+    FunctionCall test.interval-start-from-time@2[
+      LiteralExpr [STRING] [20:03:20.948]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P60DT48M389.938S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval53]
+    :
+    FunctionCall test.interval-start-from-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [20:03:20.948]
+      ]
+      LiteralExpr [STRING] [P60DT48M389.938S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval54]
+    :
+    FunctionCall test.interval-start-from-time@2[
+      LiteralExpr [STRING] [20:03:20.948]
+      LiteralExpr [STRING] [P60DT48M389.938S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval55]
+    :
+    FunctionCall test.interval-start-from-time@2[
+      LiteralExpr [NULL]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P60DT48M389.938S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval56]
+    :
+    FunctionCall test.interval-start-from-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [20:03:20.948]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval61]
+    :
+    FunctionCall test.interval-start-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-2043-11-19T15:32:39.293]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P439Y3M20DT20H39M58.949S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval62]
+    :
+    FunctionCall test.interval-start-from-datetime@2[
+      LiteralExpr [STRING] [-2043-11-19T15:32:39.293]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P439Y3M20DT20H39M58.949S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval63]
+    :
+    FunctionCall test.interval-start-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-2043-11-19T15:32:39.293]
+      ]
+      LiteralExpr [STRING] [P439Y3M20DT20H39M58.949S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval64]
+    :
+    FunctionCall test.interval-start-from-datetime@2[
+      LiteralExpr [STRING] [-2043-11-19T15:32:39.293]
+      LiteralExpr [STRING] [P439Y3M20DT20H39M58.949S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval65]
+    :
+    FunctionCall test.interval-start-from-datetime@2[
+      LiteralExpr [NULL]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P439Y3M20DT20H39M58.949S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval66]
+    :
+    FunctionCall test.interval-start-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-2043-11-19T15:32:39.293]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.3.ast
new file mode 100644
index 0000000..99d0842
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/line_01/line_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [line1]
+    :
+    FunctionCall test.line@1[
+      LiteralExpr [STRING] [10.1234,11.1e-1 +10.2E-2,-11.22]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line2]
+    :
+    FunctionCall test.line@1[
+      LiteralExpr [STRING] [0.1234,-1.00e-10 +10.5E-2,-01.02]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.3.ast
new file mode 100644
index 0000000..f7c5de0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/point_01/point_01.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [point1]
+    :
+    FunctionCall test.point@1[
+      LiteralExpr [STRING] [80.10d, -10E5]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point3d1]
+    :
+    FunctionCall test.point3d@1[
+      LiteralExpr [STRING] [5e2, -10E+5, +10.5e-10d]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point2]
+    :
+    FunctionCall test.point@1[
+      LiteralExpr [STRING] [5.10E-10d, -10E5]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point3d2]
+    :
+    FunctionCall test.point3d@1[
+      LiteralExpr [STRING] [0.5e+2d, -10.0E+5d, +10.05e-10]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast
new file mode 100644
index 0000000..86781d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [polygon1]
+    :
+    FunctionCall test.polygon@1[
+      LiteralExpr [STRING] [-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon2]
+    :
+    FunctionCall test.polygon@1[
+      LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.3.ast
new file mode 100644
index 0000000..db232e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-01/primitive-01.3.ast
@@ -0,0 +1,38 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [$a]
+    :
+    FunctionCall null.int8@1[
+      LiteralExpr [STRING] [-127]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$b]
+    :
+    FunctionCall null.int8@1[
+      LiteralExpr [STRING] [127]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$c]
+    :
+    FunctionCall null.int8@1[
+      LiteralExpr [STRING] [0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$d]
+    :
+    FunctionCall null.int8@1[
+      LiteralExpr [STRING] [1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$e]
+    :
+    FunctionCall null.int8@1[
+      LiteralExpr [STRING] [-1]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.3.ast
new file mode 100644
index 0000000..24e3507
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-02/primitive-02.3.ast
@@ -0,0 +1,52 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [$a]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [-32767]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$b]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [32767]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$c]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$d]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$e]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [-1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$f]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [16383]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$g]
+    :
+    FunctionCall null.int16@1[
+      LiteralExpr [STRING] [-16383]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.3.ast
new file mode 100644
index 0000000..c46f250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-03/primitive-03.3.ast
@@ -0,0 +1,52 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [$a]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [-2147483647]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$b]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [2147483647]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$c]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$d]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$e]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [-1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$f]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [1073741828]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$g]
+    :
+    FunctionCall null.int32@1[
+      LiteralExpr [STRING] [-1073741828]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.3.ast
new file mode 100644
index 0000000..e2136d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/primitive-04/primitive-04.3.ast
@@ -0,0 +1,52 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [$a]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [9222872036854775809]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$b]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [-9222872036854775809]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$c]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$d]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$e]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [-1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$f]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [4611436018427387904]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [$g]
+    :
+    FunctionCall null.int64@1[
+      LiteralExpr [STRING] [-4611436018427387904]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast
new file mode 100644
index 0000000..da4c509
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [rectangle1]
+    :
+    FunctionCall test.rectangle@1[
+      LiteralExpr [STRING] [5.1,11.8 87.6,15.6548]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle2]
+    :
+    FunctionCall test.rectangle@1[
+      LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast
new file mode 100644
index 0000000..8b23981
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [string1]
+    :
+    FunctionCall test.string@1[
+      LiteralExpr [STRING] [true]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [string2]
+    :
+    FunctionCall test.string@1[
+      LiteralExpr [STRING] [false"]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast
new file mode 100644
index 0000000..c9a018a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [time1]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [10:50:56.200+05:00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time2]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [10:50:56.200-10:15]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time3]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [10:50:56]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time4]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [10:50:56.200Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time5]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [23:59:59.999-13:30]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time6]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [00:00:00.000+14:45]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time7]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [12:59:00.019-01:00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time8]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [12:59:00.01-01:00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time9]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [12:59:00.019-01:00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time10]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [12590001-0100]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time11]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [125900019+0100]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast
new file mode 100644
index 0000000..e79a445
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [uuid1]
+    :
+    FunctionCall test.uuid@1[
+      LiteralExpr [STRING] [02a199ca-bf58-412e-bd9f-60a0c975a8ac]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [uuid2]
+    :
+    FunctionCall test.uuid@1[
+      LiteralExpr [STRING] [8cea25ab-55f8-467e-929d-94888f754832]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.1.ast
new file mode 100644
index 0000000..32cfc13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.1.ast
@@ -0,0 +1,24 @@
+DataverseUse student
+DataverseUse teacher
+TypeDecl stdType [
+  open RecordType {
+    id : int64,
+    name : string,
+    age : int64,
+    sex : string,
+    dept : string
+  }
+]
+TypeDecl tchrType [
+  open RecordType {
+    id : int64,
+    name : string,
+    age : int64,
+    sex : string,
+    dept : string
+  }
+]
+DatasetDecl ugdstd(stdType) partitioned by [[id]]
+DatasetDecl gdstd(stdType) partitioned by [[id]]
+DatasetDecl prof(tchrType) partitioned by [[id]]
+DatasetDecl pstdoc(tchrType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.2.ast
new file mode 100644
index 0000000..bf19720
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.2.ast
@@ -0,0 +1,2 @@
+DataverseUse student
+DataverseUse teacher
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.3.ast
new file mode 100644
index 0000000..ee08b06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv01/cross-dv01.3.ast
@@ -0,0 +1,49 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ug-student]
+    :
+    Variable [ Name=s ]
+  )
+  (
+    LiteralExpr [STRING] [prof]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [grd-student]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [postdoc]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [student.ugdstd]
+  ]
+  AS
+  Variable [ Name=s ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [teacher.prof]
+  ]
+  AS
+  Variable [ Name=p ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [student.gdstd]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [teacher.pstdoc]
+  ]
+  AS
+  Variable [ Name=b ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.1.ast
new file mode 100644
index 0000000..f18557f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.1.ast
@@ -0,0 +1,22 @@
+TypeDecl stdType [
+  open RecordType {
+    id : int32,
+    name : string,
+    age : int32,
+    sex : string,
+    dept : string
+  }
+]
+TypeDecl tchrType [
+  open RecordType {
+    id : int32,
+    name : string,
+    age : int32,
+    sex : string,
+    dept : string
+  }
+]
+DatasetDecl ugdstd(stdType) partitioned by [[id]]
+DatasetDecl gdstd(stdType) partitioned by [[id]]
+DatasetDecl prof(tchrType) partitioned by [[id]]
+DatasetDecl pstdoc(tchrType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.3.ast
new file mode 100644
index 0000000..3b61362
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv02/cross-dv02.3.ast
@@ -0,0 +1,37 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Dataset]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [student]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [teacher]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=DatasetName
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.1.ast
new file mode 100644
index 0000000..32cfc13
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.1.ast
@@ -0,0 +1,24 @@
+DataverseUse student
+DataverseUse teacher
+TypeDecl stdType [
+  open RecordType {
+    id : int64,
+    name : string,
+    age : int64,
+    sex : string,
+    dept : string
+  }
+]
+TypeDecl tchrType [
+  open RecordType {
+    id : int64,
+    name : string,
+    age : int64,
+    sex : string,
+    dept : string
+  }
+]
+DatasetDecl ugdstd(stdType) partitioned by [[id]]
+DatasetDecl gdstd(stdType) partitioned by [[id]]
+DatasetDecl prof(tchrType) partitioned by [[id]]
+DatasetDecl pstdoc(tchrType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.3.ast
new file mode 100644
index 0000000..6d01c46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv03/cross-dv03.3.ast
@@ -0,0 +1,36 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=l ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Metadata.Dataset]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=DataverseName
+          ]
+          =
+          LiteralExpr [STRING] [student]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=DataverseName
+          ]
+          =
+          LiteralExpr [STRING] [teacher]
+        ]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.1.ast
new file mode 100644
index 0000000..e9e5d1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.1.ast
@@ -0,0 +1,28 @@
+DataverseUse student
+DataverseUse teacher
+TypeDecl stdType [
+  open RecordType {
+    id : int32,
+    name : string,
+    age : int32,
+    sex : string,
+    dept : string
+  }
+]
+TypeDecl tchrType [
+  open RecordType {
+    id : int32,
+    name : string,
+    age : int32,
+    sex : string,
+    dept : string
+  }
+]
+DatasetDecl ugdstd(stdType) partitioned by [[id]]
+DatasetDecl gdstd(stdType) partitioned by [[id]]
+DatasetDecl prof(tchrType) partitioned by [[id]]
+DatasetDecl pstdoc(tchrType) partitioned by [[id]]
+DatasetDecl ugdstd(stdType) partitioned by [[id]]
+DatasetDecl gdstd(stdType) partitioned by [[id]]
+DatasetDecl prof(tchrType) partitioned by [[id]]
+DatasetDecl pstdoc(tchrType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.3.ast
new file mode 100644
index 0000000..3b61362
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv04/cross-dv04.3.ast
@@ -0,0 +1,37 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Dataset]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [student]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [teacher]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=DatasetName
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.1.ast
new file mode 100644
index 0000000..d6a98f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.1.ast
@@ -0,0 +1,10 @@
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.3.ast
new file mode 100644
index 0000000..c20010f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv07/cross-dv07.3.ast
@@ -0,0 +1,30 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test.employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Isa]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.3.ast
new file mode 100644
index 0000000..3f12d12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv09/cross-dv09.3.ast
@@ -0,0 +1,6 @@
+DataverseUse testdv1
+Query:
+SELECT ELEMENT [
+FunctionCall testdv1.fun01@0[
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.3.ast
new file mode 100644
index 0000000..3f12d12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv11/cross-dv11.3.ast
@@ -0,0 +1,6 @@
+DataverseUse testdv1
+Query:
+SELECT ELEMENT [
+FunctionCall testdv1.fun01@0[
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.3.ast
new file mode 100644
index 0000000..db93a82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv12/cross-dv12.3.ast
@@ -0,0 +1,17 @@
+DataverseUse testdv1
+DataverseUse testdv2
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [fun-01]
+    :
+    FunctionCall testdv1.fun01@0[
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fun-02]
+    :
+    FunctionCall testdv2.fun02@0[
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.3.ast
new file mode 100644
index 0000000..3f12d12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv13/cross-dv13.3.ast
@@ -0,0 +1,6 @@
+DataverseUse testdv1
+Query:
+SELECT ELEMENT [
+FunctionCall testdv1.fun01@0[
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.3.ast
new file mode 100644
index 0000000..03fc900
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv14/cross-dv14.3.ast
@@ -0,0 +1,4 @@
+DataverseUse testdv1
+Query:
+FunctionCall testdv1.fun01@0[
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.3.ast
new file mode 100644
index 0000000..b6b1bb4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv15/cross-dv15.3.ast
@@ -0,0 +1,19 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Function]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=DataverseName
+    ]
+    =
+    LiteralExpr [STRING] [testdv1]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.3.ast
new file mode 100644
index 0000000..3f12d12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv16/cross-dv16.3.ast
@@ -0,0 +1,6 @@
+DataverseUse testdv1
+Query:
+SELECT ELEMENT [
+FunctionCall testdv1.fun01@0[
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.1.ast
new file mode 100644
index 0000000..87091e3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.1.ast
@@ -0,0 +1,32 @@
+TypeDecl testtype [
+  open RecordType {
+    id : int32,
+    name : string,
+    loc : point,
+    time : datetime
+  }
+]
+TypeDecl testtype [
+  open RecordType {
+    id : int32,
+    name : string?,
+    loc : point,
+    time : datetime
+  }
+]
+TypeDecl Tweet [
+  open RecordType {
+    id : int32,
+    tweetid : int64,
+    loc : point,
+    time : datetime,
+    text : string
+  }
+]
+DatasetDecl t1(testtype) partitioned by [[id]]
+DatasetDecl t2(testtype) partitioned by [[id]]
+DatasetDecl t3(testtype) partitioned by [[id]]
+DatasetDecl t2(testtype) partitioned by [[id]]
+DatasetDecl t3(testtype) partitioned by [[id]]
+DatasetDecl t4(testtype) partitioned by [[id]]
+DatasetDecl TwitterData(Tweet)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.3.ast
new file mode 100644
index 0000000..1ed46b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv19/cross-dv19.3.ast
@@ -0,0 +1,39 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Dataset]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [test1]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [test2]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [TwitterData]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.1.ast
new file mode 100644
index 0000000..510f8d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.1.ast
@@ -0,0 +1,22 @@
+TypeDecl stdType [
+  open RecordType {
+    id : int64,
+    name : string,
+    age : int64,
+    sex : string,
+    dept : string
+  }
+]
+TypeDecl tchrType [
+  open RecordType {
+    id : int64,
+    name : string,
+    age : int64,
+    sex : string,
+    dept : string
+  }
+]
+DatasetDecl ugdstd(stdType) partitioned by [[id]]
+DatasetDecl gdstd(stdType) partitioned by [[id]]
+DatasetDecl prof(tchrType) partitioned by [[id]]
+DatasetDecl pstdoc(tchrType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.3.ast
new file mode 100644
index 0000000..ee08b06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/cross-dv20/cross-dv20.3.ast
@@ -0,0 +1,49 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [ug-student]
+    :
+    Variable [ Name=s ]
+  )
+  (
+    LiteralExpr [STRING] [prof]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [grd-student]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [postdoc]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [student.ugdstd]
+  ]
+  AS
+  Variable [ Name=s ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [teacher.prof]
+  ]
+  AS
+  Variable [ Name=p ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [student.gdstd]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [teacher.pstdoc]
+  ]
+  AS
+  Variable [ Name=b ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.1.ast
new file mode 100644
index 0000000..b0b828b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.1.ast
@@ -0,0 +1,44 @@
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.3.ast
new file mode 100644
index 0000000..3d27ea4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/insert_across_dataverses/insert_across_dataverses.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test2
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test2.Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.1.ast
new file mode 100644
index 0000000..e7b82b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.1.ast
@@ -0,0 +1,35 @@
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.2.ast
new file mode 100644
index 0000000..a5e1376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.2.ast
@@ -0,0 +1,2 @@
+DataverseUse test1
+DataverseUse test2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.3.ast
new file mode 100644
index 0000000..4e21492
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/cross-dataverse/join_across_dataverses/join_across_dataverses.3.ast
@@ -0,0 +1,81 @@
+DataverseUse test1
+DataverseUse test2
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cust_name]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cust_age]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order_total]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orderList]
+    :
+    OrderedListConstructor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=oid
+      ]
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=cid
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test1.Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test2.Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=total
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/csv/basic-types/basic-types.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/csv/basic-types/basic-types.1.ast
new file mode 100644
index 0000000..2db3f6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/csv/basic-types/basic-types.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AllType [
+  open RecordType {
+    id : int64,
+    string : string,
+    float : float,
+    double : double,
+    boolean : boolean,
+    int8 : int8,
+    int16 : int16,
+    int32 : int32,
+    int64 : int64,
+    date : date,
+    time : time,
+    datetime : datetime,
+    duration : duration,
+    point : point,
+    point3d : point3d,
+    line : line,
+    rectangle : rectangle,
+    polygon : polygon,
+    circle : circle,
+    binary : binary,
+    uuid : uuid
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/csv/basic-types/basic-types.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/csv/basic-types/basic-types.2.ast
new file mode 100644
index 0000000..ea4d950
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/csv/basic-types/basic-types.2.ast
@@ -0,0 +1,148 @@
+DataverseUse test
+Set output-record-type=AllType
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    LiteralExpr [LONG] [10]
+  )
+  (
+    LiteralExpr [STRING] [string]
+    :
+    FunctionCall test.string@1[
+      LiteralExpr [STRING] [Nancy]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    LiteralExpr [FLOAT] [32.5]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [-2013.5938237483274]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [boolean]
+    :
+    LiteralExpr [TRUE]
+  )
+  (
+    LiteralExpr [STRING] [int8]
+    :
+    FunctionCall test.int8@1[
+      LiteralExpr [STRING] [125]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int16]
+    :
+    FunctionCall test.int16@1[
+      LiteralExpr [STRING] [32765]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int32]
+    :
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [294967295]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [int64]
+    :
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [1700000000000000000]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date]
+    :
+    FunctionCall test.date@1[
+      LiteralExpr [STRING] [-2011-01-27]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time]
+    :
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [12:20:30Z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime]
+    :
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [-1951-12-27T12:20:30]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration]
+    :
+    FunctionCall test.duration@1[
+      LiteralExpr [STRING] [P10Y11M12DT10H50M30S]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point]
+    :
+    FunctionCall test.point@1[
+      LiteralExpr [STRING] [41.00,44.00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [point3d]
+    :
+    FunctionCall test.point3d@1[
+      LiteralExpr [STRING] [44.00,13.00,41.00]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [line]
+    :
+    FunctionCall test.line@1[
+      LiteralExpr [STRING] [10.1,11.1 10.2,11.2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangle]
+    :
+    FunctionCall test.rectangle@1[
+      LiteralExpr [STRING] [5.1,11.8 87.6,15.6548]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [polygon]
+    :
+    FunctionCall test.polygon@1[
+      LiteralExpr [STRING] [1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle]
+    :
+    FunctionCall test.circle@1[
+      LiteralExpr [STRING] [10.1,11.1 10.2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [binary]
+    :
+    FunctionCall test.hex@1[
+      LiteralExpr [STRING] [ABCDEF0123456789]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [uuid]
+    :
+    FunctionCall test.uuid@1[
+      LiteralExpr [STRING] [5c848e5c-6b6a-498f-8452-8847a2957421]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.1.ast
new file mode 100644
index 0000000..d1a7252
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.3.ast
new file mode 100644
index 0000000..bc6dd44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_01/customer_q_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.1.ast
new file mode 100644
index 0000000..e279376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.3.ast
new file mode 100644
index 0000000..e2ed544
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_02/customer_q_02.3.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nestedRecord]
+    :
+    Variable [ Name=nestedRec ]
+  )
+  (
+    LiteralExpr [STRING] [order_id]
+    :
+    FieldAccessor [
+      Variable [ Name=nestedRec ]
+      Field=oid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=nestedRec ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=lastorder
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.1.ast
new file mode 100644
index 0000000..e279376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.3.ast
new file mode 100644
index 0000000..43fa189
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_03/customer_q_03.3.ast
@@ -0,0 +1,99 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [list1]
+    :
+    Variable [ Name=c1 ]
+  )
+  (
+    LiteralExpr [STRING] [list2]
+    :
+    Variable [ Name=c2 ]
+  )
+  (
+    LiteralExpr [STRING] [list3]
+    :
+    Variable [ Name=c3 ]
+  )
+  (
+    LiteralExpr [STRING] [list4]
+    :
+    Variable [ Name=c4 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=nestedRec ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=lastorder
+  ]
+LetVariable [ Name=c1 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    FieldAccessor [
+      Variable [ Name=nestedRec ]
+      Field=oid
+    ]
+  ]
+LetVariable [ Name=c2 ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    FieldAccessor [
+      Variable [ Name=nestedRec ]
+      Field=oid
+    ]
+  ]
+LetVariable [ Name=c3 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=lastorder
+    ]
+    Variable [ Name=nestedRec ]
+  ]
+LetVariable [ Name=c4 ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=lastorder
+    ]
+    Variable [ Name=nestedRec ]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    >=
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [3]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.1.ast
new file mode 100644
index 0000000..e279376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast
new file mode 100644
index 0000000..55224c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_04/customer_q_04.3.ast
@@ -0,0 +1,120 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [custname]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [age]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [MathcashBack]
+    :
+    Variable [ Name=rec ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=rec ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [cashBack]
+      :
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=cashBack
+      ]
+    )
+    (
+      LiteralExpr [STRING] [cashBack+5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=cashBack
+        ]
+        +
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [cashBack-5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=cashBack
+        ]
+        -
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [cashBack*5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=cashBack
+        ]
+        *
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [cashBack/5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=cashBack
+        ]
+        /
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [-cashBack]
+      :
+      NEGATIVE FieldAccessor [
+  Variable [ Name=c ]
+  Field=cashBack
+]
+    )
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    >=
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [3]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.1.ast
new file mode 100644
index 0000000..e279376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast
new file mode 100644
index 0000000..736d958
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_05/customer_q_05.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [custname]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [age]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [MathAge]
+    :
+    Variable [ Name=rec ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=rec ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [age]
+      :
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=age
+      ]
+    )
+    (
+      LiteralExpr [STRING] [age+5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=age
+        ]
+        +
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [age-5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=age
+        ]
+        -
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [age*5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=age
+        ]
+        *
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [age/5]
+      :
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=age
+        ]
+        /
+        LiteralExpr [LONG] [5]
+      ]
+    )
+    (
+      LiteralExpr [STRING] [-age]
+      :
+      NEGATIVE FieldAccessor [
+  Variable [ Name=c ]
+  Field=age
+]
+    )
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    >=
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [3]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.1.ast
new file mode 100644
index 0000000..d1a7252
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.3.ast
new file mode 100644
index 0000000..641bb90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_06/customer_q_06.3.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customerid]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orderedlist]
+    :
+    Variable [ Name=n ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=rec ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=lastorder
+  ]
+LetVariable [ Name=m ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    FieldAccessor [
+      Variable [ Name=rec ]
+      Field=oid
+    ]
+  ]
+LetVariable [ Name=n ]
+  :=
+  OrderedListConstructor [
+    IndexAccessor [
+      Variable [ Name=m ]
+      Index: ANY
+    ]
+    IndexAccessor [
+      Variable [ Name=m ]
+      Index:       Variable [ Name=m ]
+    ]
+    IndexAccessor [
+      Variable [ Name=m ]
+      Index:       Variable [ Name=m ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.1.ast
new file mode 100644
index 0000000..d1a7252
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.3.ast
new file mode 100644
index 0000000..578f555
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_07/customer_q_07.3.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [customerid]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [unorderedlist]
+    :
+    Variable [ Name=n ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=rec ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=lastorder
+  ]
+LetVariable [ Name=m ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    FieldAccessor [
+      Variable [ Name=rec ]
+      Field=oid
+    ]
+  ]
+LetVariable [ Name=n ]
+  :=
+  UnorderedListConstructor [
+    IndexAccessor [
+      Variable [ Name=m ]
+      Index: ANY
+    ]
+    IndexAccessor [
+      Variable [ Name=m ]
+      Index:       Variable [ Name=m ]
+    ]
+    IndexAccessor [
+      Variable [ Name=m ]
+      Index:       Variable [ Name=m ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.1.ast
new file mode 100644
index 0000000..d1a7252
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.3.ast
new file mode 100644
index 0000000..24260b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/customer_q_08/customer_q_08.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [custname]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [custage]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [15]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.1.ast
new file mode 100644
index 0000000..ec381af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.1.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+TypeDecl CustomerOrdersType [
+  open RecordType {
+    cid : int64,
+    cust : CustomerType,
+    orders : OrderedList [OrderType]
+
+  }
+]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
+DatasetDecl Orders2(OrderType) partitioned by [[oid]]
+DatasetDecl CustomerOrders2(CustomerOrdersType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.3.ast
new file mode 100644
index 0000000..329c11c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/denorm-cust-order_02/denorm-cust-order_02.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=co ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CustomerOrders2]
+  ]
+  AS
+  Variable [ Name=co ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=co ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.1.ast
new file mode 100644
index 0000000..7509a02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.1.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.3.ast
new file mode 100644
index 0000000..6891291
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_01/join_q_01.3.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cust_name]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cust_age]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order_total]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orderList]
+    :
+    OrderedListConstructor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=oid
+      ]
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=cid
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=total
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.1.ast
new file mode 100644
index 0000000..7509a02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.1.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.3.ast
new file mode 100644
index 0000000..04e5cfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_02/join_q_02.3.ast
@@ -0,0 +1,106 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cust_name]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order_total]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orderedlist]
+    :
+    Variable [ Name=ol ]
+  )
+  (
+    LiteralExpr [STRING] [unorderedlist]
+    :
+    Variable [ Name=ul ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=rec ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=lastorder
+  ]
+LetVariable [ Name=ol ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=rec ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+LetVariable [ Name=ul ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=rec ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=total
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.1.ast
new file mode 100644
index 0000000..7509a02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.1.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.3.ast
new file mode 100644
index 0000000..ca77585
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_03/join_q_03.3.ast
@@ -0,0 +1,138 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cust_name]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [order_total]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orderedlist]
+    :
+    Variable [ Name=ol ]
+  )
+  (
+    LiteralExpr [STRING] [unorderedlist]
+    :
+    Variable [ Name=ul ]
+  )
+  (
+    LiteralExpr [STRING] [ol_item1]
+    :
+    IndexAccessor [
+      Variable [ Name=ol ]
+      Index:       Variable [ Name=ol ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ol_item2]
+    :
+    IndexAccessor [
+      Variable [ Name=ol ]
+      Index:       Variable [ Name=ol ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ol_item5]
+    :
+    IndexAccessor [
+      Variable [ Name=ol ]
+      Index:       Variable [ Name=ol ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ul_item1]
+    :
+    IndexAccessor [
+      Variable [ Name=ul ]
+      Index: ANY
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=rec ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=lastorder
+  ]
+LetVariable [ Name=ol ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=rec ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+LetVariable [ Name=ul ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=rec ]
+      Field=oid
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=total
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/join_q_04/join_q_04.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.1.ast
new file mode 100644
index 0000000..9132f14
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl c1(CustomerType) partitioned by [[cid]]
+DatasetDecl c2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.4.ast
new file mode 100644
index 0000000..f37252c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/load-test/load-test.4.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [c2]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.1.ast
new file mode 100644
index 0000000..2865318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.3.ast
new file mode 100644
index 0000000..63d9290
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_01/order_q_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=c ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.1.ast
new file mode 100644
index 0000000..2865318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.3.ast
new file mode 100644
index 0000000..15c61b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_02/order_q_02.3.ast
@@ -0,0 +1,120 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [list1]
+    :
+    Variable [ Name=c1 ]
+  )
+  (
+    LiteralExpr [STRING] [list2]
+    :
+    Variable [ Name=c2 ]
+  )
+  (
+    LiteralExpr [STRING] [list3]
+    :
+    Variable [ Name=c3 ]
+  )
+  (
+    LiteralExpr [STRING] [list4]
+    :
+    Variable [ Name=c4 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=c1 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=orderstatus
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=clerk
+    ]
+  ]
+LetVariable [ Name=c2 ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=orderstatus
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=clerk
+    ]
+  ]
+LetVariable [ Name=c3 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=loc
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=lastorder
+    ]
+  ]
+LetVariable [ Name=c4 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=loc
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=lastorder
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.1.ast
new file mode 100644
index 0000000..2865318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.3.ast
new file mode 100644
index 0000000..2431b79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_03/order_q_03.3.ast
@@ -0,0 +1,137 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [orderid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ordertot]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [list]
+    :
+    Variable [ Name=c1 ]
+  )
+  (
+    LiteralExpr [STRING] [item1]
+    :
+    IndexAccessor [
+      Variable [ Name=c1 ]
+      Index:       Variable [ Name=c1 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [item2]
+    :
+    IndexAccessor [
+      Variable [ Name=c1 ]
+      Index:       Variable [ Name=c1 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [item3]
+    :
+    IndexAccessor [
+      Variable [ Name=c1 ]
+      Index:       Variable [ Name=c1 ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=c1 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=orderstatus
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=clerk
+    ]
+  ]
+LetVariable [ Name=c2 ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=orderstatus
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=clerk
+    ]
+  ]
+LetVariable [ Name=c3 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=loc
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=lastorder
+    ]
+  ]
+LetVariable [ Name=c4 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=loc
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=lastorder
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.1.ast
new file mode 100644
index 0000000..2865318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.3.ast
new file mode 100644
index 0000000..29368a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_04/order_q_04.3.ast
@@ -0,0 +1,145 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [orderid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ordertot]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [list]
+    :
+    Variable [ Name=c3 ]
+  )
+  (
+    LiteralExpr [STRING] [item1]
+    :
+    IndexAccessor [
+      Variable [ Name=c3 ]
+      Index:       Variable [ Name=c3 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [item2]
+    :
+    IndexAccessor [
+      Variable [ Name=c3 ]
+      Index:       Variable [ Name=c3 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [item5]
+    :
+    IndexAccessor [
+      Variable [ Name=c3 ]
+      Index:       Variable [ Name=c3 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [item10]
+    :
+    IndexAccessor [
+      Variable [ Name=c3 ]
+      Index:       Variable [ Name=c3 ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=c1 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=orderstatus
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=clerk
+    ]
+  ]
+LetVariable [ Name=c2 ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=orderstatus
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=clerk
+    ]
+  ]
+LetVariable [ Name=c3 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=loc
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=lastorder
+    ]
+  ]
+LetVariable [ Name=c4 ]
+  :=
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=loc
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=lastorder
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.1.ast
new file mode 100644
index 0000000..2865318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.3.ast
new file mode 100644
index 0000000..9b46c2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_05/order_q_05.3.ast
@@ -0,0 +1,70 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [orderid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ordertot]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=total
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emptyorderedlist]
+    :
+    Variable [ Name=c1 ]
+  )
+  (
+    LiteralExpr [STRING] [emptyunorderedlist]
+    :
+    Variable [ Name=c2 ]
+  )
+  (
+    LiteralExpr [STRING] [olist_item1]
+    :
+    IndexAccessor [
+      Variable [ Name=c1 ]
+      Index:       Variable [ Name=c1 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [olist_item5]
+    :
+    IndexAccessor [
+      Variable [ Name=c1 ]
+      Index:       Variable [ Name=c1 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ulist_item1]
+    :
+    IndexAccessor [
+      Variable [ Name=c2 ]
+      Index: ANY
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=c1 ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=c2 ]
+  :=
+  UnorderedListConstructor [
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.1.ast
new file mode 100644
index 0000000..2865318
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.3.ast
new file mode 100644
index 0000000..102d550
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/custord/order_q_06/order_q_06.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [item1]
+    :
+    IndexAccessor [
+      Variable [ Name=c3 ]
+      Index: ANY
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=c3 ]
+  :=
+  UnorderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=heList
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=openlist
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.1.ast
new file mode 100644
index 0000000..ccfb888
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    street : string,
+    city : string,
+    zip : string,
+    latlong : point
+  }
+]
+TypeDecl UserType [
+  open RecordType {
+    name : string,
+    email : string,
+    interests : UnorderedList <string>
+,
+    address : AddressType,
+    member_of : UnorderedList <          open RecordType {
+            sig_id : int64,
+            chapter_name : string,
+            member_since : date
+          }
+>
+
+  }
+]
+DatasetDecl User(UserType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.3.ast
new file mode 100644
index 0000000..d4993ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q1/q1.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [User]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=i ]
+    In
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=i ]
+        =
+        LiteralExpr [STRING] [movies]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.1.ast
new file mode 100644
index 0000000..b8ae596
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    street : string,
+    city : string,
+    zip : string,
+    latlong : point
+  }
+]
+TypeDecl EventType [
+  closed RecordType {
+    event_id : int64,
+    name : string,
+    location : AddressType?,
+    organizers : UnorderedList <          open RecordType {
+            name : string
+          }
+>
+,
+    sponsoring_sigs : OrderedList [          open RecordType {
+            sig_id : int64,
+            chapter_name : string
+          }
+]
+,
+    interest_keywords : UnorderedList <string>
+,
+    price : double?,
+    start_time : datetime,
+    end_time : datetime
+  }
+]
+DatasetDecl Event(EventType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.3.ast
new file mode 100644
index 0000000..ac677df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dapd/q2/q2.3.ast
@@ -0,0 +1,113 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sig_id]
+    :
+    Variable [ Name=sig_id ]
+  )
+  (
+    LiteralExpr [STRING] [total_count]
+    :
+    Variable [ Name=sig_sponsorship_count ]
+  )
+  (
+    LiteralExpr [STRING] [chapter_breakdown]
+    :
+    Variable [ Name=by_chapter ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Event]
+  ]
+  AS
+  Variable [ Name=event ]
+,
+  FieldAccessor [
+    Variable [ Name=event ]
+    Field=sponsoring_sigs
+  ]
+  AS
+  Variable [ Name=sponsor ]
+]
+LetVariable [ Name=es ]
+  :=
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [event]
+      :
+      Variable [ Name=event ]
+    )
+    (
+      LiteralExpr [STRING] [sponsor]
+      :
+      Variable [ Name=sponsor ]
+    )
+  ]
+Groupby
+  Variable [ Name=sig_id ]
+  :=
+  FieldAccessor [
+    Variable [ Name=sponsor ]
+    Field=sig_id
+  ]
+  With
+  Variable [ Name=es ]
+  Variable [ Name=sponsor ]
+  Variable [ Name=event ]
+
+LetVariable [ Name=sig_sponsorship_count ]
+  :=
+  FunctionCall test.count@1[
+    Variable [ Name=es ]
+  ]
+LetVariable [ Name=by_chapter ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [chapter_name]
+        :
+        Variable [ Name=chapter_name ]
+      )
+      (
+        LiteralExpr [STRING] [escount]
+        :
+        FunctionCall test.count@1[
+          Variable [ Name=e ]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=es ]
+      AS
+      Variable [ Name=e ]
+    ]
+    Groupby
+      Variable [ Name=chapter_name ]
+      :=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=e ]
+          Field=sponsor
+        ]
+        Field=chapter_name
+      ]
+      With
+      Variable [ Name=e ]
+      Variable [ Name=by_chapter ]
+      Variable [ Name=sig_sponsorship_count ]
+      Variable [ Name=es ]
+      Variable [ Name=sponsor ]
+      Variable [ Name=event ]
+
+  )
+Orderby
+  Variable [ Name=sig_sponsorship_count ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [5]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/distinct/query-issue443-2/query-issue443-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/distinct/query-issue443-2/query-issue443-2.1.ast
new file mode 100644
index 0000000..4073865
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/distinct/query-issue443-2/query-issue443-2.1.ast
@@ -0,0 +1,69 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [f]
+        :
+        LiteralExpr [LONG] [19]
+      )
+      (
+        LiteralExpr [STRING] [g]
+        :
+        LiteralExpr [LONG] [1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [f]
+        :
+        LiteralExpr [LONG] [12]
+      )
+      (
+        LiteralExpr [STRING] [g]
+        :
+        LiteralExpr [LONG] [2]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [f]
+        :
+        LiteralExpr [LONG] [10]
+      )
+      (
+        LiteralExpr [STRING] [g]
+        :
+        LiteralExpr [LONG] [1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [f]
+        :
+        LiteralExpr [LONG] [17]
+      )
+      (
+        LiteralExpr [STRING] [g]
+        :
+        LiteralExpr [LONG] [1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [f]
+        :
+        LiteralExpr [LONG] [12]
+      )
+      (
+        LiteralExpr [STRING] [g]
+        :
+        LiteralExpr [LONG] [4]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/distinct/query-issue443/query-issue443.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/distinct/query-issue443/query-issue443.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/distinct/query-issue443/query-issue443.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.1.ast
new file mode 100644
index 0000000..c3adfcb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    salary : double?,
+    name : string,
+    durtn : duration?,
+    inter : interval,
+    dt : date?,
+    tm : time,
+    pt : point?
+  }
+]
+TypeDecl TestType [
+  closed RecordType {
+    id : int32,
+    salary : double?,
+    name : string,
+    durtn : duration?,
+    inter : interval,
+    dt : date?,
+    tm : time,
+    pt : point?
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.3.ast
new file mode 100644
index 0000000..9504111
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-cltype/create-drop-cltype.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Datatype]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=DatatypeName
+    ]
+    =
+    LiteralExpr [STRING] [TestType]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.1.ast
new file mode 100644
index 0000000..32a41ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    salary : double?,
+    name : string,
+    durtn : duration?,
+    inter : interval,
+    dt : date?,
+    tm : time,
+    pt : point?
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    salary : double?,
+    name : string,
+    durtn : duration?,
+    inter : interval,
+    dt : date?,
+    tm : time,
+    pt : point?
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.3.ast
new file mode 100644
index 0000000..9504111
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/create-drop-opntype/create-drop-opntype.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Datatype]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=DatatypeName
+    ]
+    =
+    LiteralExpr [STRING] [TestType]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.3.ast
new file mode 100644
index 0000000..55c7a87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-from-loaded-dataset/delete-from-loaded-dataset.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.3.ast
new file mode 100644
index 0000000..b3586b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-multi-statement/delete-multi-statement.3.ast
@@ -0,0 +1,11 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.3.ast
new file mode 100644
index 0000000..55c7a87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/delete-syntax-change/delete-syntax-change.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ast
new file mode 100644
index 0000000..2e844ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    first : string,
+    last : string
+  }
+]
+TypeDecl Person [
+  open RecordType {
+    name : Name
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    name : string,
+    locn : point,
+    zip : string,
+    person : Person
+  }
+]
+DatasetDecl t1(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.ast
new file mode 100644
index 0000000..7600062
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Index]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=IsPrimary
+    ]
+    =
+    LiteralExpr [FALSE]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.1.ast
new file mode 100644
index 0000000..bbc2751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    unique1 : int64,
+    unique2 : int64,
+    two : int64,
+    four : int64,
+    ten : int64,
+    twenty : int64,
+    onePercent : int64,
+    tenPercent : int64,
+    twentyPercent : int64,
+    fiftyPercent : int64,
+    unique3 : int64,
+    evenOnePercent : int64,
+    oddOnePercent : int64,
+    stringu1 : string,
+    stringu2 : string,
+    string4 : string
+  }
+]
+DatasetDecl t1(Schema) partitioned by [[unique2]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.4.ast
new file mode 100644
index 0000000..de91ce6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/drop-index/drop-index.4.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t1]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=unique1
+      ]
+      >
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=stringu1
+      ]
+      =
+      LiteralExpr [STRING] [DGAAAAXXXXXXXXXXXXXXXXXXX]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.3.ast
new file mode 100644
index 0000000..125e278
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/empty-load-with-index/empty-load-with-index.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [1]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ast
new file mode 100644
index 0000000..8181f54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.ast
new file mode 100644
index 0000000..d3cf8a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test.employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.1.ast
new file mode 100644
index 0000000..537173f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl myDataType [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl myData(myDataType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.3.ast
new file mode 100644
index 0000000..c200c21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-dataset/insert-and-scan-dataset.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [myData]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-and-scan-joined-datasets/insert-and-scan-joined-datasets.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.1.ast
new file mode 100644
index 0000000..150c083
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.1.ast
@@ -0,0 +1,12 @@
+DataverseUse STBench
+TypeDecl SimpleGeoPlaceType [
+  closed RecordType {
+    coordinates : point,
+    id : int64,
+    name : string,
+    tags : string,
+    categories : string,
+    phone : string
+  }
+]
+DatasetDecl SimpleGeoPlace(SimpleGeoPlaceType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.2.ast
new file mode 100644
index 0000000..1ce7249
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.2.ast
@@ -0,0 +1 @@
+DataverseUse STBench
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-duplicated-keys/insert-duplicated-keys.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ast
new file mode 100644
index 0000000..c6576b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.ast
new file mode 100644
index 0000000..fe0604d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_linenumber
+      ]
+      <
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.1.ast
new file mode 100644
index 0000000..c6576b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.3.ast
new file mode 100644
index 0000000..fe0604d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-empty-dataset/insert-into-empty-dataset.3.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_linenumber
+      ]
+      <
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ast
new file mode 100644
index 0000000..c6576b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.ast
new file mode 100644
index 0000000..2312f4d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      =
+      LiteralExpr [LONG] [3]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_linenumber
+      ]
+      =
+      LiteralExpr [LONG] [2]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ast
new file mode 100644
index 0000000..e0e93c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.ast
new file mode 100644
index 0000000..fe0604d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_linenumber
+      ]
+      <
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.1.ast
new file mode 100644
index 0000000..c6576b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.3.ast
new file mode 100644
index 0000000..fe0604d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_01/insert-into-loaded-dataset_01.3.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_linenumber
+      ]
+      <
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.1.ast
new file mode 100644
index 0000000..2067a51
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.1.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    unique1 : int64,
+    unique2 : int64,
+    two : int64,
+    four : int64,
+    ten : int64,
+    twenty : int64,
+    onePercent : int64,
+    tenPercent : int64,
+    twentyPercent : int64,
+    fiftyPercent : int64,
+    unique3 : int64,
+    evenOnePercent : int64,
+    oddOnePercent : int64,
+    stringu1 : string,
+    stringu2 : string,
+    string4 : string
+  }
+]
+DatasetDecl onektup(Schema) partitioned by [[unique2]]
+DatasetDecl tenktup1(Schema) partitioned by [[unique2]]
+DatasetDecl tmp(Schema) partitioned by [[unique2]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.3.ast
new file mode 100644
index 0000000..2e2d27e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-into-loaded-dataset_02/insert-into-loaded-dataset_02.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=t ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tmp]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=unique2
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.1.ast
new file mode 100644
index 0000000..6ce44ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.1.ast
@@ -0,0 +1,14 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  closed RecordType {
+    id : string,
+    name : string?
+  }
+]
+TypeDecl testtype02 [
+  closed RecordType {
+    id : string
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.3.ast
new file mode 100644
index 0000000..07560d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-src-dst-01/insert-src-dst-01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.1.ast
new file mode 100644
index 0000000..88a28ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.1.ast
@@ -0,0 +1,8 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  open RecordType {
+    id : int64,
+    name : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.3.ast
new file mode 100644
index 0000000..ecce0a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-syntax/insert-syntax.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.1.ast
new file mode 100644
index 0000000..15e635f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.3.ast
new file mode 100644
index 0000000..32586e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_01/insert-with-autogenerated-pk_adm_01.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Extending]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.1.ast
new file mode 100644
index 0000000..15e635f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.3.ast
new file mode 100644
index 0000000..32586e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_02/insert-with-autogenerated-pk_adm_02.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Extending]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.1.ast
new file mode 100644
index 0000000..613af93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.3.ast
new file mode 100644
index 0000000..12df2e7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert-with-autogenerated-pk_adm_03/insert-with-autogenerated-pk_adm_03.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Extending]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.1.ast
new file mode 100644
index 0000000..e0e93c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.3.ast
new file mode 100644
index 0000000..2a8182e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert/insert.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.1.ast
new file mode 100644
index 0000000..e0e93c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineIDType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_linenumber : int64,
+    l_suppkey : int64
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineID(LineIDType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.3.ast
new file mode 100644
index 0000000..2a8182e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/insert_less_nc/insert_less_nc.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineID]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.1.ast
new file mode 100644
index 0000000..15e635f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.3.ast
new file mode 100644
index 0000000..d163e5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_01/load-with-autogenerated-pk_adm_01.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Authorization in Object-Oriented Databases.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.1.ast
new file mode 100644
index 0000000..15e635f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.3.ast
new file mode 100644
index 0000000..d163e5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_02/load-with-autogenerated-pk_adm_01.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Authorization in Object-Oriented Databases.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.1.ast
new file mode 100644
index 0000000..a5e79ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    dblpid : string,
+    id : uuid,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.3.ast
new file mode 100644
index 0000000..d163e5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_03/load-with-autogenerated-pk_adm_03.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Authorization in Object-Oriented Databases.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.1.ast
new file mode 100644
index 0000000..613af93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.3.ast
new file mode 100644
index 0000000..d163e5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_adm_04/load-with-autogenerated-pk_adm_04.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Authorization in Object-Oriented Databases.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.1.ast
new file mode 100644
index 0000000..2a2fc43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    title : string,
+    authors : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.3.ast
new file mode 100644
index 0000000..d163e5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_01/load-with-autogenerated-pk_csv_01.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Authorization in Object-Oriented Databases.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.1.ast
new file mode 100644
index 0000000..2a2fc43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    title : string,
+    authors : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.3.ast
new file mode 100644
index 0000000..d163e5a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_csv_02/load-with-autogenerated-pk_csv_02.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Authorization in Object-Oriented Databases.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.1.ast
new file mode 100644
index 0000000..2a2fc43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : uuid,
+    title : string,
+    authors : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.3.ast
new file mode 100644
index 0000000..fdb741c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-autogenerated-pk_txt_01/load-with-autogenerated-pk_txt_01.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=title
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Physical Object Management.]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.1.ast
new file mode 100644
index 0000000..da0f9db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.1.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemTypeOpen [
+  open RecordType {
+    l_orderkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItemOpen(LineItemTypeOpen) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.3.ast
new file mode 100644
index 0000000..f68f911
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index-open/load-with-index-open.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItemOpen]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_partkey
+    ]
+    =
+    LiteralExpr [LONG] [100]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.3.ast
new file mode 100644
index 0000000..6f47149
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-index/load-with-index.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_partkey
+    ]
+    =
+    LiteralExpr [LONG] [100]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.1.ast
new file mode 100644
index 0000000..598a32c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPTypeOpen [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPTypeOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.3.ast
new file mode 100644
index 0000000..78199ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index-open/load-with-ngram-index-open.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.1.ast
new file mode 100644
index 0000000..3a8b89a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.3.ast
new file mode 100644
index 0000000..00a8321
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-ngram-index/load-with-ngram-index.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.1.ast
new file mode 100644
index 0000000..cb10b17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyDataOpen(MyRecordOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.3.ast
new file mode 100644
index 0000000..3f769c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index-open/load-with-rtree-index-open.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyDataOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.1.ast
new file mode 100644
index 0000000..a706d77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.3.ast
new file mode 100644
index 0000000..613b78d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-rtree-index/load-with-rtree-index.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.1.ast
new file mode 100644
index 0000000..598a32c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPTypeOpen [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPTypeOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.3.ast
new file mode 100644
index 0000000..0009875
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index-open/load-with-word-index-open.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.1.ast
new file mode 100644
index 0000000..3a8b89a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.3.ast
new file mode 100644
index 0000000..996effe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/load-with-word-index/load-with-word-index.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ast
new file mode 100644
index 0000000..29b4565
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ast
@@ -0,0 +1,30 @@
+DataverseUse testdv2
+TypeDecl AddressType [
+  open RecordType {
+    street : string,
+    city : string
+  }
+]
+TypeDecl Dept [
+  open RecordType {
+    name : string,
+    id : int64
+  }
+]
+TypeDecl testtype [
+  closed RecordType {
+    name : string,
+    id : string,
+    address : AddressType?,
+    department : UnorderedList <Dept>
+?
+  }
+]
+TypeDecl testtype2 [
+  open RecordType {
+    name : string,
+    id : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
+DatasetDecl testds2(testtype2) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.ast
new file mode 100644
index 0000000..40b2443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds2]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.1.ast
new file mode 100644
index 0000000..4ac7598
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.1.ast
@@ -0,0 +1,16 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  closed RecordType {
+    id : string,
+    name : string,
+    hobby : UnorderedList <string>
+?
+  }
+]
+TypeDecl testtype2 [
+  open RecordType {
+    id : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
+DatasetDecl testds2(testtype2) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.3.ast
new file mode 100644
index 0000000..40b2443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-c2o/opentype-c2o.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds2]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.1.ast
new file mode 100644
index 0000000..3c94e67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.1.ast
@@ -0,0 +1,8 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  closed RecordType {
+    name : string?,
+    id : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.3.ast
new file mode 100644
index 0000000..ecce0a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-closed-optional/opentype-closed-optional.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.1.ast
new file mode 100644
index 0000000..dce72b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.1.ast
@@ -0,0 +1,8 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.3.ast
new file mode 100644
index 0000000..180a22c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert/opentype-insert.3.ast
@@ -0,0 +1,11 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=d ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.1.ast
new file mode 100644
index 0000000..cc72abc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.3.ast
new file mode 100644
index 0000000..25fd257
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-insert2/opentype-insert2.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.1.ast
new file mode 100644
index 0000000..dca7a9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.1.ast
@@ -0,0 +1,8 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  open RecordType {
+    name : string?,
+    id : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.3.ast
new file mode 100644
index 0000000..ecce0a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-noexpand/opentype-noexpand.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ast
new file mode 100644
index 0000000..4c2827d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ast
@@ -0,0 +1,30 @@
+DataverseUse testdv2
+TypeDecl AddressType [
+  open RecordType {
+    street : string,
+    city : string
+  }
+]
+TypeDecl Dept [
+  closed RecordType {
+    name : string,
+    id : int64
+  }
+]
+TypeDecl testtype [
+  open RecordType {
+    name : string,
+    id : string
+  }
+]
+TypeDecl testtype2 [
+  closed RecordType {
+    name : string,
+    id : string,
+    address : AddressType?,
+    department : UnorderedList <Dept>
+?
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
+DatasetDecl testds2(testtype2) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.ast
new file mode 100644
index 0000000..40b2443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds2]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.1.ast
new file mode 100644
index 0000000..1614ff8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.1.ast
@@ -0,0 +1,17 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+TypeDecl testtype2 [
+  closed RecordType {
+    hobby : UnorderedList <string>
+?,
+    id : string,
+    name : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
+DatasetDecl testds2(testtype2) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.3.ast
new file mode 100644
index 0000000..40b2443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2c/opentype-o2c.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds2]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.1.ast
new file mode 100644
index 0000000..fad25ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.1.ast
@@ -0,0 +1,16 @@
+DataverseUse testdv2
+TypeDecl testtype [
+  open RecordType {
+    name : string,
+    id : string
+  }
+]
+TypeDecl testtype2 [
+  open RecordType {
+    id : string,
+    name : string,
+    hobby : string
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
+DatasetDecl testds2(testtype2) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.3.ast
new file mode 100644
index 0000000..40b2443
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/opentype-o2o/opentype-o2o.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds2]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue205/query-issue205.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.5.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue288/query-issue288.5.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.1.ast
new file mode 100644
index 0000000..f3fdefa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.1.ast
@@ -0,0 +1,24 @@
+DataverseUse SocialNetworkData
+TypeDecl EmploymentType [
+  closed RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    id-copy : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    user-since-copy : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl HandbookUsers(FacebookUserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.2.ast
new file mode 100644
index 0000000..119f3ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.2.ast
@@ -0,0 +1 @@
+DataverseUse SocialNetworkData
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.3.ast
new file mode 100644
index 0000000..46bda0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue382/query-issue382.3.ast
@@ -0,0 +1,17 @@
+DataverseUse SocialNetworkData
+Query:
+SELECT ELEMENT [
+FunctionCall SocialNetworkData.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=h ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [HandbookUsers]
+      ]
+      AS
+      Variable [ Name=h ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/query-issue433/query-issue433.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..50026d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..9fa8d85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.1.ast
new file mode 100644
index 0000000..0c653db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerOpenType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl CustomersOpen(CustomerOpenType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.5.ast
new file mode 100644
index 0000000..c6100d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-btree-secondary-index-open/scan-delete-btree-secondary-index-open.5.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CustomersOpen]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..bf08fc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..00a8321
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.5.ast
new file mode 100644
index 0000000..78199ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index-open/scan-delete-inverted-index-ngram-secondary-index-open.5.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.ast
new file mode 100644
index 0000000..00a8321
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..bf08fc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..996effe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.1.ast
new file mode 100644
index 0000000..6d2fcec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.5.ast
new file mode 100644
index 0000000..0009875
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index-open/scan-delete-inverted-index-word-secondary-index-open.5.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.ast
new file mode 100644
index 0000000..996effe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..b16a7f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point?,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..613b78d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.1.ast
new file mode 100644
index 0000000..cb10b17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyDataOpen(MyRecordOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.5.ast
new file mode 100644
index 0000000..3f769c5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index-open/scan-delete-rtree-secondary-index-open.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyDataOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast
new file mode 100644
index 0000000..a706d77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast
new file mode 100644
index 0000000..613b78d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..dd0071c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl CustomersMini(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..23d7439
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CustomersMini]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.1.ast
new file mode 100644
index 0000000..0c653db
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerOpenType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl CustomersOpen(CustomerOpenType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.5.ast
new file mode 100644
index 0000000..c6100d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-btree-secondary-index-open/scan-insert-btree-secondary-index-open.5.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CustomersOpen]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..f126afe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..b68b640
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP1]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.5.ast
new file mode 100644
index 0000000..78199ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index-open/scan-insert-inverted-index-ngram-secondary-index-open.5.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ast
new file mode 100644
index 0000000..3a8b89a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.ast
new file mode 100644
index 0000000..b68b640
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP1]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..f126afe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..f175f19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP1]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.5.ast
new file mode 100644
index 0000000..0009875
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index-open/scan-insert-inverted-index-word-secondary-index-open.5.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ast
new file mode 100644
index 0000000..3a8b89a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.ast
new file mode 100644
index 0000000..f175f19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP1]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..220b664
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point?,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    id : int64,
+    point : point?
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..986505d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ast
@@ -0,0 +1,2 @@
+DataverseUse test
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..1b0eba1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.1.ast
new file mode 100644
index 0000000..5d73cb4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyOpenRecord [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyOpenData(MyOpenRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.5.ast
new file mode 100644
index 0000000..b0060e2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index-open/scan-insert-rtree-secondary-index-open.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyOpenData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast
new file mode 100644
index 0000000..647b510
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    id : int64,
+    point : point
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast
new file mode 100644
index 0000000..1b0eba1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.1.ast
new file mode 100644
index 0000000..988d604
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.1.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+TypeDecl EmpType [
+  open RecordType {
+    id : int64,
+    name : string,
+    address :       open RecordType {
+        number : int64,
+        street : string,
+        city : string
+      }
+,
+    age : int64?,
+    interests : UnorderedList <string>
+?,
+    children : OrderedList [string]
+?
+  }
+]
+DatasetDecl Emp(EmpType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.3.ast
new file mode 100644
index 0000000..b0e1330
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_01/q_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=e ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Emp]
+  ]
+  AS
+  Variable [ Name=e ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.1.ast
new file mode 100644
index 0000000..988d604
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.1.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+TypeDecl EmpType [
+  open RecordType {
+    id : int64,
+    name : string,
+    address :       open RecordType {
+        number : int64,
+        street : string,
+        city : string
+      }
+,
+    age : int64?,
+    interests : UnorderedList <string>
+?,
+    children : OrderedList [string]
+?
+  }
+]
+DatasetDecl Emp(EmpType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.3.ast
new file mode 100644
index 0000000..742e574
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/employee/q_02/q_02.3.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Emp]
+  ]
+  AS
+  Variable [ Name=e ]
+]
+LetVariable [ Name=m ]
+  :=
+  OrderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [EmpName]
+        :
+        FieldAccessor [
+          Variable [ Name=e ]
+          Field=name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [parent_interest_1]
+        :
+        IndexAccessor [
+          FieldAccessor [
+            Variable [ Name=e ]
+            Field=interests
+          ]
+          Index: ANY
+        ]
+      )
+      (
+        LiteralExpr [STRING] [child1Name]
+        :
+        IndexAccessor [
+          FieldAccessor [
+            Variable [ Name=e ]
+            Field=children
+          ]
+          Index: ANY
+        ]
+      )
+      (
+        LiteralExpr [STRING] [child2Name]
+        :
+        IndexAccessor [
+          FieldAccessor [
+            Variable [ Name=e ]
+            Field=children
+          ]
+          Index:           FieldAccessor [
+            Variable [ Name=e ]
+            Field=children
+          ]
+        ]
+      )
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
new file mode 100644
index 0000000..4becfa4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
new file mode 100644
index 0000000..317564b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ast
new file mode 100644
index 0000000..4becfa4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.ast
new file mode 100644
index 0000000..d3b6da5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rc-format/rc-format.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.1.ast
new file mode 100644
index 0000000..183ae54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.3.ast
new file mode 100644
index 0000000..fe2fa6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/rtree-index/rtree-index.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/sequence-format/sequence-format.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/external-indexing/text-format/text-format.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.1.ast
new file mode 100644
index 0000000..db3764c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.5.ast
new file mode 100644
index 0000000..0ec6003
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/equality-predicate/equality-predicate.5.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=m ]
+      Field=send-time
+    ]
+    =
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [2014-01-20T10:10:00]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.1.ast
new file mode 100644
index 0000000..378ac63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl FacebookMessages2(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.5.ast
new file mode 100644
index 0000000..698c900
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-btree/insert-with-secondary-btree.5.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages2]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=author-id
+      ]
+      =
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      >
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-08-20T10:10:00]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-11-20T10:10:00]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.1.ast
new file mode 100644
index 0000000..378ac63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl FacebookMessages2(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.5.ast
new file mode 100644
index 0000000..307feb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-ngram/insert-with-secondary-inverted-ngram.5.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=message
+      ]
+      LiteralExpr [STRING] [love]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-12-20T10:10:00]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=send-time
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.1.ast
new file mode 100644
index 0000000..378ac63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl FacebookMessages2(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.5.ast
new file mode 100644
index 0000000..b429922
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-inverted-word/insert-with-secondary-inverted-word.5.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=m ]
+            Field=message
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          LiteralExpr [STRING] [love sprint at&t verizon]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-12-20T10:10:00]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=send-time
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.1.ast
new file mode 100644
index 0000000..378ac63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl FacebookMessages2(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.5.ast
new file mode 100644
index 0000000..3258cf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert-with-secondary-rtree/insert-with-secondary-rtree.5.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=sender-location
+      ]
+      FunctionCall test.create-polygon@1[
+        OrderedListConstructor [
+          LiteralExpr [DOUBLE] [40.0]
+          LiteralExpr [DOUBLE] [79.87]
+          LiteralExpr [DOUBLE] [30.0]
+          LiteralExpr [DOUBLE] [75.0]
+          LiteralExpr [DOUBLE] [50.0]
+          LiteralExpr [DOUBLE] [80.0]
+          LiteralExpr [DOUBLE] [10.0]
+          LiteralExpr [DOUBLE] [10.0]
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-11-20T10:10:00.000Z]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=send-time
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.1.ast
new file mode 100644
index 0000000..378ac63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl FacebookMessages2(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.5.ast
new file mode 100644
index 0000000..c4eb26a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/insert/insert.5.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages2]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=m ]
+      Field=send-time
+    ]
+    >
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [2012-08-20T10:10:00]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.1.ast
new file mode 100644
index 0000000..db3764c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.5.ast
new file mode 100644
index 0000000..b32e113
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-btree/load-with-secondary-btree.5.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=author-id
+      ]
+      =
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      >
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-08-20T10:10:00]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-11-20T10:10:00]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.1.ast
new file mode 100644
index 0000000..db3764c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.5.ast
new file mode 100644
index 0000000..307feb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-ngram/load-with-secondary-inverted-ngram.5.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=message
+      ]
+      LiteralExpr [STRING] [love]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-12-20T10:10:00]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=send-time
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.1.ast
new file mode 100644
index 0000000..db3764c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.5.ast
new file mode 100644
index 0000000..b429922
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-inverted-word/load-with-secondary-inverted-word.5.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=m ]
+            Field=message
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          LiteralExpr [STRING] [love sprint at&t verizon]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-12-20T10:10:00]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=send-time
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.1.ast
new file mode 100644
index 0000000..db3764c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.5.ast
new file mode 100644
index 0000000..3258cf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load-with-secondary-rtree/load-with-secondary-rtree.5.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=sender-location
+      ]
+      FunctionCall test.create-polygon@1[
+        OrderedListConstructor [
+          LiteralExpr [DOUBLE] [40.0]
+          LiteralExpr [DOUBLE] [79.87]
+          LiteralExpr [DOUBLE] [30.0]
+          LiteralExpr [DOUBLE] [75.0]
+          LiteralExpr [DOUBLE] [50.0]
+          LiteralExpr [DOUBLE] [80.0]
+          LiteralExpr [DOUBLE] [10.0]
+          LiteralExpr [DOUBLE] [10.0]
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=m ]
+        Field=send-time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-11-20T10:10:00.000Z]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=m ]
+    Field=send-time
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.1.ast
new file mode 100644
index 0000000..db3764c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string,
+    send-time : datetime
+  }
+]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.5.ast
new file mode 100644
index 0000000..a033dff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/filters/load/load.5.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=m ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=m ]
+      Field=send-time
+    ]
+    >
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [2012-08-20T10:10:00]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.3.ast
new file mode 100644
index 0000000..d3860d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.3.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=gen0 ]
+      Field=partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [pid]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [shipdate]
+    :
+    FieldAccessor [
+      Variable [ Name=j ]
+      Field=l_shipdate
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [partkey]
+        :
+        Variable [ Name=partkey ]
+      )
+      (
+        LiteralExpr [STRING] [i]
+        :
+        Variable [ Name=i ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Groupby
+      Variable [ Name=partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_partkey
+      ]
+      With
+      Variable [ Name=i ]
+
+  )
+  AS
+  Variable [ Name=gen0 ]
+,
+  FieldAccessor [
+    Variable [ Name=gen0 ]
+    Field=i
+  ]
+  AS
+  Variable [ Name=j ]
+  AT
+  Variable [ Name=p ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=p ]
+    <
+    LiteralExpr [LONG] [4]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.4.ast
new file mode 100644
index 0000000..d3860d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.4.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=gen0 ]
+      Field=partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [pid]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [shipdate]
+    :
+    FieldAccessor [
+      Variable [ Name=j ]
+      Field=l_shipdate
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [partkey]
+        :
+        Variable [ Name=partkey ]
+      )
+      (
+        LiteralExpr [STRING] [i]
+        :
+        Variable [ Name=i ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Groupby
+      Variable [ Name=partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_partkey
+      ]
+      With
+      Variable [ Name=i ]
+
+  )
+  AS
+  Variable [ Name=gen0 ]
+,
+  FieldAccessor [
+    Variable [ Name=gen0 ]
+    Field=i
+  ]
+  AS
+  Variable [ Name=j ]
+  AT
+  Variable [ Name=p ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=p ]
+    <
+    LiteralExpr [LONG] [4]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.5.ast
new file mode 100644
index 0000000..d3860d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at00/at00.5.ast
@@ -0,0 +1,77 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=gen0 ]
+      Field=partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [pid]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [shipdate]
+    :
+    FieldAccessor [
+      Variable [ Name=j ]
+      Field=l_shipdate
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [partkey]
+        :
+        Variable [ Name=partkey ]
+      )
+      (
+        LiteralExpr [STRING] [i]
+        :
+        Variable [ Name=i ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Groupby
+      Variable [ Name=partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_partkey
+      ]
+      With
+      Variable [ Name=i ]
+
+  )
+  AS
+  Variable [ Name=gen0 ]
+,
+  FieldAccessor [
+    Variable [ Name=gen0 ]
+    Field=i
+  ]
+  AS
+  Variable [ Name=j ]
+  AT
+  Variable [ Name=p ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=p ]
+    <
+    LiteralExpr [LONG] [4]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.1.ast
new file mode 100644
index 0000000..3c2818d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.3.ast
new file mode 100644
index 0000000..1aafc34
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at01/at01.3.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [num]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [user-since]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=user-since
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    Variable [ Name=fb ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=fb ]
+    ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=fb ]
+        Field=name
+      ]
+      ASC
+
+  )
+  AS
+  Variable [ Name=i ]
+  AT
+  Variable [ Name=p ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.1.ast
new file mode 100644
index 0000000..c9be9ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.3.ast
new file mode 100644
index 0000000..d6863cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at02/at02.3.ast
@@ -0,0 +1,94 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [group]
+    :
+    Variable [ Name=g ]
+  )
+  (
+    LiteralExpr [STRING] [item]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [num]
+          :
+          Variable [ Name=p ]
+        )
+        (
+          LiteralExpr [STRING] [mid]
+          :
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=message-id
+          ]
+        )
+      ]
+      ]
+      FROM [        (
+          SELECT ELEMENT [
+          Variable [ Name=ii ]
+          ]
+          FROM [            Variable [ Name=m ]
+            AS
+            Variable [ Name=ii ]
+          ]
+          Orderby
+            FieldAccessor [
+              Variable [ Name=ii ]
+              Field=message-id
+            ]
+            ASC
+
+        )
+        AS
+        Variable [ Name=a ]
+        AT
+        Variable [ Name=p ]
+      ]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=u ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=u ]
+      Field=id
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=m ]
+      Field=author-id
+    ]
+  ]
+Groupby
+  Variable [ Name=g ]
+  :=
+  FieldAccessor [
+    Variable [ Name=u ]
+    Field=id
+  ]
+  With
+  Variable [ Name=u ]
+  Variable [ Name=m ]
+
+Orderby
+  Variable [ Name=g ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.1.ast
new file mode 100644
index 0000000..77fb76a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int32,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.3.ast
new file mode 100644
index 0000000..eda838d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at03/at03.3.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user-since]
+    :
+    Variable [ Name=fus ]
+  )
+  (
+    LiteralExpr [STRING] [users]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [num]
+          :
+          Variable [ Name=ip ]
+        )
+        (
+          LiteralExpr [STRING] [name]
+          :
+          FieldAccessor [
+            Variable [ Name=f ]
+            Field=name
+          ]
+        )
+      ]
+      ]
+      FROM [        (
+          SELECT ELEMENT [
+          Variable [ Name=i1 ]
+          ]
+          FROM [            Variable [ Name=i ]
+            AS
+            Variable [ Name=i1 ]
+          ]
+          Orderby
+            FieldAccessor [
+              Variable [ Name=i1 ]
+              Field=name
+            ]
+            ASC
+
+        )
+        AS
+        Variable [ Name=f ]
+        AT
+        Variable [ Name=ip ]
+      ]
+    )
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    Variable [ Name=fb ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=fb ]
+    ]
+  )
+  AS
+  Variable [ Name=i ]
+]
+Groupby
+  Variable [ Name=fus ]
+  :=
+  FunctionCall test.get-year@1[
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=user-since
+    ]
+  ]
+  With
+  Variable [ Name=i ]
+
+Orderby
+  Variable [ Name=fus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.1.ast
new file mode 100644
index 0000000..de69a42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.3.ast
new file mode 100644
index 0000000..0efaa7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at04/at04.3.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    Variable [ Name=ckey ]
+  )
+  (
+    LiteralExpr [STRING] [users]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [num]
+          :
+          Variable [ Name=ip ]
+        )
+        (
+          LiteralExpr [STRING] [orderkey]
+          :
+          FieldAccessor [
+            Variable [ Name=f ]
+            Field=o_orderkey
+          ]
+        )
+      ]
+      ]
+      FROM [        (
+          SELECT ELEMENT [
+          Variable [ Name=i1 ]
+          ]
+          FROM [            Variable [ Name=i ]
+            AS
+            Variable [ Name=i1 ]
+          ]
+          Orderby
+            FieldAccessor [
+              Variable [ Name=i1 ]
+              Field=o_orderkey
+            ]
+            ASC
+
+        )
+        AS
+        Variable [ Name=f ]
+        AT
+        Variable [ Name=ip ]
+      ]
+    )
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    Variable [ Name=o ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+    ]
+  )
+  AS
+  Variable [ Name=i ]
+]
+Groupby
+  Variable [ Name=ckey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=o_custkey
+  ]
+  With
+  Variable [ Name=i ]
+
+Orderby
+  Variable [ Name=ckey ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [3]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.1.ast
new file mode 100644
index 0000000..de69a42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.3.ast
new file mode 100644
index 0000000..a3d85c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at05/at05.3.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=si ]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [xx]
+        :
+        Variable [ Name=xx ]
+      )
+      (
+        LiteralExpr [STRING] [x]
+        :
+        Variable [ Name=x ]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        Variable [ Name=uid ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=x ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=o_custkey
+        ]
+        <
+        LiteralExpr [LONG] [4]
+      ]
+    Groupby
+      Variable [ Name=uid ]
+      :=
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=o_custkey
+      ]
+      With
+      Variable [ Name=x ]
+
+    LetVariable [ Name=xx ]
+      :=
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [uid]
+            :
+            Variable [ Name=uid ]
+          )
+          (
+            LiteralExpr [STRING] [seq]
+            :
+            Variable [ Name=i ]
+          )
+          (
+            LiteralExpr [STRING] [item]
+            :
+            FieldAccessor [
+              Variable [ Name=y ]
+              Field=o_orderkey
+            ]
+          )
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            Variable [ Name=xxx ]
+            ]
+            FROM [              Variable [ Name=x ]
+              AS
+              Variable [ Name=xxx ]
+            ]
+            Orderby
+              FieldAccessor [
+                Variable [ Name=xxx ]
+                Field=o_orderkey
+              ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=y ]
+          AT
+          Variable [ Name=i ]
+        ]
+      )
+    Orderby
+      Variable [ Name=uid ]
+      ASC
+
+  )
+  AS
+  Variable [ Name=gen0 ]
+,
+  FieldAccessor [
+    Variable [ Name=gen0 ]
+    Field=xx
+  ]
+  AS
+  Variable [ Name=si ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.3.ast
new file mode 100644
index 0000000..224ce62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/at06/at06.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=gen0 ]
+      Field=partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [pid]
+    :
+    Variable [ Name=p ]
+  )
+  (
+    LiteralExpr [STRING] [shipdate]
+    :
+    FieldAccessor [
+      Variable [ Name=j ]
+      Field=l_shipdate
+    ]
+  )
+  (
+    LiteralExpr [STRING] [orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=j ]
+      Field=l_orderkey
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [partkey]
+        :
+        Variable [ Name=partkey ]
+      )
+      (
+        LiteralExpr [STRING] [i]
+        :
+        Variable [ Name=i ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Groupby
+      Variable [ Name=partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_partkey
+      ]
+      With
+      Variable [ Name=i ]
+
+  )
+  AS
+  Variable [ Name=gen0 ]
+,
+  (
+    SELECT ELEMENT [
+    Variable [ Name=ii ]
+    ]
+    FROM [      FieldAccessor [
+        Variable [ Name=gen0 ]
+        Field=i
+      ]
+      AS
+      Variable [ Name=ii ]
+    ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=ii ]
+        Field=l_shipdate
+      ]
+      ASC
+
+  )
+  AS
+  Variable [ Name=j ]
+  AT
+  Variable [ Name=p ]
+]
+Where
+  OperatorExpr [
+    Variable [ Name=p ]
+    <
+    LiteralExpr [LONG] [4]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.3.ast
new file mode 100644
index 0000000..416cf4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/flwor/query-issue550/query-issue550.3.ast
@@ -0,0 +1,186 @@
+Query:
+LetVariable [ Name=sample ]
+  :=
+  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [1]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:00:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [2]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:01:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e2]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [3]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [3c4d]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:02:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [4]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [3c4d]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:03:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e3]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [5]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:04:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [r]
+        :
+        LiteralExpr [LONG] [6]
+      )
+      (
+        LiteralExpr [STRING] [uid]
+        :
+        LiteralExpr [STRING] [1a2b]
+      )
+      (
+        LiteralExpr [STRING] [t]
+        :
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-01-01T01:05:00]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [event]
+        :
+        LiteralExpr [STRING] [e4]
+      )
+    ]
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [u]
+    :
+    Variable [ Name=u ]
+  )
+  (
+    LiteralExpr [STRING] [recs]
+    :
+    (
+      SELECT ELEMENT [
+      Variable [ Name=srec ]
+      ]
+      FROM [        Variable [ Name=s ]
+        AS
+        Variable [ Name=srec ]
+      ]
+    )
+  )
+]
+]
+FROM [  Variable [ Name=sample ]
+  AS
+  Variable [ Name=s ]
+]
+Groupby
+  Variable [ Name=u ]
+  :=
+  FieldAccessor [
+    Variable [ Name=s ]
+    Field=uid
+  ]
+  With
+  Variable [ Name=s ]
+  Variable [ Name=sample ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.3.ast
new file mode 100644
index 0000000..eb3fed5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_1/dblp-1_1.3.ast
@@ -0,0 +1,37 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=tokenGroupped ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=token ]
+]
+Groupby
+  Variable [ Name=tokenGroupped ]
+  :=
+  Variable [ Name=token ]
+  With
+  Variable [ Name=paper ]
+  Variable [ Name=token ]
+
+Orderby
+  FunctionCall fuzzyjoin.count@1[
+    Variable [ Name=paper ]
+  ]
+  ASC
+  Variable [ Name=tokenGroupped ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.ast
new file mode 100644
index 0000000..6c5f7137
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.3.ast
new file mode 100644
index 0000000..099a27b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1.1/dblp-1_2.3.ast
@@ -0,0 +1,44 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=tokenGroupped ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=token ]
+]
+LetVariable [ Name=id ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+Groupby
+  Variable [ Name=tokenGroupped ]
+  :=
+  Variable [ Name=token ]
+  With
+  Variable [ Name=id ]
+  Variable [ Name=paper ]
+  Variable [ Name=token ]
+
+Orderby
+  FunctionCall fuzzyjoin.count@1[
+    Variable [ Name=id ]
+  ]
+  ASC
+  Variable [ Name=tokenGroupped ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.ast
new file mode 100644
index 0000000..eb88893
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.3.ast
new file mode 100644
index 0000000..099a27b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2.1/dblp-1_2.3.ast
@@ -0,0 +1,44 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=tokenGroupped ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=token ]
+]
+LetVariable [ Name=id ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+Groupby
+  Variable [ Name=tokenGroupped ]
+  :=
+  Variable [ Name=token ]
+  With
+  Variable [ Name=id ]
+  Variable [ Name=paper ]
+  Variable [ Name=token ]
+
+Orderby
+  FunctionCall fuzzyjoin.count@1[
+    Variable [ Name=id ]
+  ]
+  ASC
+  Variable [ Name=tokenGroupped ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.1.ast
new file mode 100644
index 0000000..eb88893
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.3.ast
new file mode 100644
index 0000000..c487f14
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-1_2/dblp-1_2.3.ast
@@ -0,0 +1,44 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=tokenGroupped ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=token ]
+]
+LetVariable [ Name=paperid ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+Groupby
+  Variable [ Name=tokenGroupped ]
+  :=
+  Variable [ Name=token ]
+  With
+  Variable [ Name=paperid ]
+  Variable [ Name=paper ]
+  Variable [ Name=token ]
+
+Orderby
+  FunctionCall fuzzyjoin.count@1[
+    Variable [ Name=paperid ]
+  ]
+  ASC
+  Variable [ Name=tokenGroupped ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1.ast
new file mode 100644
index 0000000..f048108
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.3.ast
new file mode 100644
index 0000000..1b78185
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.1_5.3.1/dblp-2.3.ast
@@ -0,0 +1,142 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [prefixToken]
+    :
+    Variable [ Name=prefixTokenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [lenDBLP]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.1.ast
new file mode 100644
index 0000000..c0b39dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.1.ast
@@ -0,0 +1,18 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl TOKENSRANKEDADMType [
+  closed RecordType {
+    token : int64,
+    rank : int64
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl TOKENSRANKEDADM(TOKENSRANKEDADMType) partitioned by [[rank]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.3.ast
new file mode 100644
index 0000000..5fcb123
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2.2/dblp-2.3.ast
@@ -0,0 +1,106 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [prefixToken]
+    :
+    Variable [ Name=prefixTokenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=tokenRanked ]
+      Field=rank
+    ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [TOKENSRANKEDADM]
+      ]
+      AS
+      Variable [ Name=tokenRanked ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        FieldAccessor [
+          Variable [ Name=tokenRanked ]
+          Field=token
+        ]
+      ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=tokenRanked ]
+        Field=rank
+      ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=prefixTokenDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.3.ast
new file mode 100644
index 0000000..a2c468a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_1/dblp-2_1.3.ast
@@ -0,0 +1,103 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=paper ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.3.ast
new file mode 100644
index 0000000..41ce531
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_2/dblp-2_2.3.ast
@@ -0,0 +1,110 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.3.ast
new file mode 100644
index 0000000..c9e4e57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_3/dblp-2_3.3.ast
@@ -0,0 +1,111 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.3.ast
new file mode 100644
index 0000000..30f198b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_4/dblp-2_4.3.ast
@@ -0,0 +1,115 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.3.ast
new file mode 100644
index 0000000..079ed12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.1/dblp-2_5.3.ast
@@ -0,0 +1,126 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [len]
+    :
+    Variable [ Name=lenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.3.ast
new file mode 100644
index 0000000..079ed12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.2/dblp-2_5.3.ast
@@ -0,0 +1,126 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [len]
+    :
+    Variable [ Name=lenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.1.ast
new file mode 100644
index 0000000..f048108
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.ast
new file mode 100644
index 0000000..079ed12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3.1/dblp-2_5.3.ast
@@ -0,0 +1,126 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [len]
+    :
+    Variable [ Name=lenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.ast
new file mode 100644
index 0000000..079ed12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5.3/dblp-2_5.3.ast
@@ -0,0 +1,126 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [len]
+    :
+    Variable [ Name=lenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.3.ast
new file mode 100644
index 0000000..146d718
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-2_5/dblp-2_5.3.ast
@@ -0,0 +1,126 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [len]
+    :
+    Variable [ Name=lenDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [tokens]
+    :
+    Variable [ Name=tokensDBLP ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.3.ast
new file mode 100644
index 0000000..dd8bc7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.1/dblp-3_1.3.ast
@@ -0,0 +1,376 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [left]
+    :
+    Variable [ Name=paperLeft ]
+  )
+  (
+    LiteralExpr [STRING] [right]
+    :
+    Variable [ Name=paperRight ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idLeft]
+        :
+        Variable [ Name=idLeft ]
+      )
+      (
+        LiteralExpr [STRING] [idRight]
+        :
+        Variable [ Name=idRight ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperLeft ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensLeft]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenLeft]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenLeft ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperRight ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensRight]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenRight]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenRight ]
+    ]
+    LetVariable [ Name=lenLeft ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperLeft ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensLeft ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=lenRight ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperRight ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensRight ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensRight ]
+              Variable [ Name=lenRight ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenLeft ]
+        Variable [ Name=tokensLeft ]
+        Variable [ Name=lenRight ]
+        Variable [ Name=tokensRight ]
+        Variable [ Name=prefixTokenLeft ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenLeft ]
+          =
+          Variable [ Name=prefixTokenRight ]
+        ]
+        and
+        OperatorExpr [
+          OperatorExpr [
+            Variable [ Name=sim ]
+            >=
+            LiteralExpr [FLOAT] [0.5]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=id
+            ]
+            <
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=id
+            ]
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idLeft ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+      Variable [ Name=idRight ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensRight ]
+      Variable [ Name=lenRight ]
+      Variable [ Name=tokensLeft ]
+      Variable [ Name=lenLeft ]
+      Variable [ Name=paperLeft ]
+      Variable [ Name=paperRight ]
+      Variable [ Name=prefixTokenRight ]
+      Variable [ Name=prefixTokenLeft ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperLeft ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperRight ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idLeft
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idRight
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperLeft ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperRight ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.3.ast
new file mode 100644
index 0000000..dd8bc7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1.2/dblp-3_1.3.ast
@@ -0,0 +1,376 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [left]
+    :
+    Variable [ Name=paperLeft ]
+  )
+  (
+    LiteralExpr [STRING] [right]
+    :
+    Variable [ Name=paperRight ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idLeft]
+        :
+        Variable [ Name=idLeft ]
+      )
+      (
+        LiteralExpr [STRING] [idRight]
+        :
+        Variable [ Name=idRight ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperLeft ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensLeft]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenLeft]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenLeft ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperRight ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensRight]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenRight]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenRight ]
+    ]
+    LetVariable [ Name=lenLeft ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperLeft ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensLeft ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=lenRight ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperRight ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensRight ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensRight ]
+              Variable [ Name=lenRight ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenLeft ]
+        Variable [ Name=tokensLeft ]
+        Variable [ Name=lenRight ]
+        Variable [ Name=tokensRight ]
+        Variable [ Name=prefixTokenLeft ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenLeft ]
+          =
+          Variable [ Name=prefixTokenRight ]
+        ]
+        and
+        OperatorExpr [
+          OperatorExpr [
+            Variable [ Name=sim ]
+            >=
+            LiteralExpr [FLOAT] [0.5]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=id
+            ]
+            <
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=id
+            ]
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idLeft ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+      Variable [ Name=idRight ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensRight ]
+      Variable [ Name=lenRight ]
+      Variable [ Name=tokensLeft ]
+      Variable [ Name=lenLeft ]
+      Variable [ Name=paperLeft ]
+      Variable [ Name=paperRight ]
+      Variable [ Name=prefixTokenRight ]
+      Variable [ Name=prefixTokenLeft ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperLeft ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperRight ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idLeft
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idRight
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperLeft ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperRight ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.3.ast
new file mode 100644
index 0000000..0881303
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-3_1/dblp-3_1.3.ast
@@ -0,0 +1,382 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [left]
+    :
+    Variable [ Name=paperLeft ]
+  )
+  (
+    LiteralExpr [STRING] [right]
+    :
+    Variable [ Name=paperRight ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperLeft ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperRight ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idLeft]
+        :
+        Variable [ Name=idLeft ]
+      )
+      (
+        LiteralExpr [STRING] [idRight]
+        :
+        Variable [ Name=idRight ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperLeft ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensLeft]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenLeft]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenLeft ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperRight ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensRight]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [lenRight]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenRight ]
+    ]
+    LetVariable [ Name=lenLeft ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperLeft ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensLeft ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=lenRight ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=paperRight ]
+            Field=title
+          ]
+        ]
+      ]
+    LetVariable [ Name=tokensRight ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensRight ]
+              Variable [ Name=lenRight ]
+              Variable [ Name=tokensLeft ]
+              Variable [ Name=lenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+              Variable [ Name=prefixTokenRight ]
+              Variable [ Name=prefixTokenLeft ]
+              Variable [ Name=paperLeft ]
+              Variable [ Name=paperRight ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenLeft ]
+        Variable [ Name=tokensLeft ]
+        Variable [ Name=lenRight ]
+        Variable [ Name=tokensRight ]
+        Variable [ Name=prefixTokenLeft ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenLeft ]
+          =
+          Variable [ Name=prefixTokenRight ]
+        ]
+        and
+        OperatorExpr [
+          OperatorExpr [
+            Variable [ Name=sim ]
+            >=
+            LiteralExpr [FLOAT] [0.5]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=paperLeft ]
+              Field=id
+            ]
+            <
+            FieldAccessor [
+              Variable [ Name=paperRight ]
+              Field=id
+            ]
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idLeft ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+      Variable [ Name=idRight ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensRight ]
+      Variable [ Name=lenRight ]
+      Variable [ Name=tokensLeft ]
+      Variable [ Name=lenLeft ]
+      Variable [ Name=paperLeft ]
+      Variable [ Name=paperRight ]
+      Variable [ Name=prefixTokenRight ]
+      Variable [ Name=prefixTokenLeft ]
+      Variable [ Name=paperLeft ]
+      Variable [ Name=paperRight ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idLeft
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperLeft ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idRight
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperRight ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperLeft ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperRight ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.1.ast
new file mode 100644
index 0000000..f048108
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.3.ast
new file mode 100644
index 0000000..e37e938
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_1/dblp-aqlplus_1.3.ast
@@ -0,0 +1,71 @@
+DataverseUse fuzzyjoin
+Set simthreshold=.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=dblp ]
+  )
+  (
+    LiteralExpr [STRING] [dblp2]
+    :
+    Variable [ Name=dblp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall fuzzyjoin.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=dblp ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall fuzzyjoin.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=dblp2 ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=dblp ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=dblp2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=dblp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dblp2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.1.ast
new file mode 100644
index 0000000..11bff7c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.1.ast
@@ -0,0 +1,7 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.3.ast
new file mode 100644
index 0000000..21dc41f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-aqlplus_2/dblp-aqlplus_2.3.ast
@@ -0,0 +1,67 @@
+DataverseUse fuzzyjoin
+Set simthreshold=.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=dblp ]
+  )
+  (
+    LiteralExpr [STRING] [dblp2]
+    :
+    Variable [ Name=dblp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=dblp ]
+        Field=title
+      ]
+      ~=
+      FieldAccessor [
+        Variable [ Name=dblp2 ]
+        Field=title
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=dblp ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=dblp2 ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=dblp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dblp2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.ast
new file mode 100644
index 0000000..2b3eae0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_1/dblp-csx-2_1.3.ast
@@ -0,0 +1,287 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=paper ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=paper ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    FunctionCall fuzzyjoin.len@1[
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    ]
+    Variable [ Name=tokensDBLP ]
+    FunctionCall fuzzyjoin.len@1[
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  Variable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  Variable [ Name=sim ]
+  :=
+  Variable [ Name=sim ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.ast
new file mode 100644
index 0000000..cb13cd0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_2/dblp-csx-2_2.3.ast
@@ -0,0 +1,301 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    FunctionCall fuzzyjoin.len@1[
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    ]
+    Variable [ Name=tokensDBLP ]
+    FunctionCall fuzzyjoin.len@1[
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  Variable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  Variable [ Name=sim ]
+  :=
+  Variable [ Name=sim ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.ast
new file mode 100644
index 0000000..ffc00ff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_3/dblp-csx-2_3.3.ast
@@ -0,0 +1,312 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    FunctionCall fuzzyjoin.len@1[
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    ]
+    Variable [ Name=tokensDBLP ]
+    FunctionCall fuzzyjoin.len@1[
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  Variable [ Name=sim ]
+  :=
+  Variable [ Name=sim ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.ast
new file mode 100644
index 0000000..ccb4e12
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_4/dblp-csx-2_4.3.ast
@@ -0,0 +1,313 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedCSX ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedCSX ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    FunctionCall fuzzyjoin.len@1[
+      Variable [ Name=tokensUnrankedDBLP ]
+    ]
+    Variable [ Name=tokensDBLP ]
+    FunctionCall fuzzyjoin.len@1[
+      Variable [ Name=tokensUnrankedCSX ]
+    ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  Variable [ Name=sim ]
+  :=
+  Variable [ Name=sim ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=tokensUnrankedCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=tokensUnrankedDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.3.ast
new file mode 100644
index 0000000..4996286
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.1/dblp-csx-2_5.3.ast
@@ -0,0 +1,321 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedCSX ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenCSX ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedCSX ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedCSX ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    Variable [ Name=lenDBLP ]
+    Variable [ Name=tokensDBLP ]
+    Variable [ Name=lenCSX ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=lenCSX ]
+  Variable [ Name=tokensUnrankedCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=lenDBLP ]
+  Variable [ Name=tokensUnrankedDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.3.ast
new file mode 100644
index 0000000..4996286
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.2/dblp-csx-2_5.3.ast
@@ -0,0 +1,321 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedCSX ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenCSX ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedCSX ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedCSX ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    Variable [ Name=lenDBLP ]
+    Variable [ Name=tokensDBLP ]
+    Variable [ Name=lenCSX ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=lenCSX ]
+  Variable [ Name=tokensUnrankedCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=lenDBLP ]
+  Variable [ Name=tokensUnrankedDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.1.ast
new file mode 100644
index 0000000..94ba64d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.ast
new file mode 100644
index 0000000..c131cbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3.1/dblp-csx-2_5.3.ast
@@ -0,0 +1,324 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedCSX ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenCSX ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedCSX ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedCSX ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    Variable [ Name=lenDBLP ]
+    Variable [ Name=tokensDBLP ]
+    Variable [ Name=lenCSX ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  Variable [ Name=sim ]
+  :=
+  Variable [ Name=sim ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=lenCSX ]
+  Variable [ Name=tokensUnrankedCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=lenDBLP ]
+  Variable [ Name=tokensUnrankedDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.ast
new file mode 100644
index 0000000..4996286
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5.3/dblp-csx-2_5.3.ast
@@ -0,0 +1,321 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedCSX ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenCSX ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedCSX ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedCSX ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGrouped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGrouped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGrouped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    Variable [ Name=lenDBLP ]
+    Variable [ Name=tokensDBLP ]
+    Variable [ Name=lenCSX ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=lenCSX ]
+  Variable [ Name=tokensUnrankedCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=lenDBLP ]
+  Variable [ Name=tokensUnrankedDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.ast
new file mode 100644
index 0000000..c131cbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-2_5/dblp-csx-2_5.3.ast
@@ -0,0 +1,324 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [idDBLP]
+    :
+    Variable [ Name=idDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [idCSX]
+    :
+    Variable [ Name=idCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    IndexAccessor [
+      Variable [ Name=sim ]
+      Index:       Variable [ Name=sim ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensDBLP]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  FunctionCall fuzzyjoin.subset-collection@3[
+    FunctionCall Metadata.dataset@1[
+      LiteralExpr [STRING] [tokensCSX]
+    ]
+    LiteralExpr [LONG] [0]
+    FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+      FunctionCall fuzzyjoin.len@1[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+      ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+  AS
+  Variable [ Name=prefixTokenCSX ]
+]
+LetVariable [ Name=idDBLP ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedDBLP ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperDBLP ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenDBLP ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedDBLP ]
+  ]
+LetVariable [ Name=tokensDBLP ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=idCSX ]
+  :=
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+LetVariable [ Name=tokensUnrankedCSX ]
+  :=
+  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=lenCSX ]
+  :=
+  FunctionCall fuzzyjoin.len@1[
+    Variable [ Name=tokensUnrankedCSX ]
+  ]
+LetVariable [ Name=tokensCSX ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=tokensUnrankedCSX ]
+      AS
+      Variable [ Name=tokenUnranked ]
+,
+      (
+        SELECT ELEMENT [
+        Variable [ Name=tokenGroupped ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paper ]
+,
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paper ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=token ]
+        ]
+        LetVariable [ Name=id ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paper ]
+            Field=id
+          ]
+        Groupby
+          Variable [ Name=tokenGroupped ]
+          :=
+          Variable [ Name=token ]
+          With
+          Variable [ Name=id ]
+          Variable [ Name=paper ]
+          Variable [ Name=token ]
+          Variable [ Name=tokenUnranked ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+
+        Orderby
+          FunctionCall fuzzyjoin.count@1[
+            Variable [ Name=id ]
+          ]
+          ASC
+          Variable [ Name=tokenGroupped ]
+          ASC
+
+      )
+      AS
+      Variable [ Name=tokenRanked ]
+      AT
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        Variable [ Name=tokenUnranked ]
+        =
+        Variable [ Name=tokenRanked ]
+      ]
+    Orderby
+      Variable [ Name=i ]
+      ASC
+
+  )
+LetVariable [ Name=sim ]
+  :=
+  FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+    Variable [ Name=lenDBLP ]
+    Variable [ Name=tokensDBLP ]
+    Variable [ Name=lenCSX ]
+    Variable [ Name=tokensCSX ]
+    Variable [ Name=prefixTokenDBLP ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=prefixTokenDBLP ]
+      =
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=sim ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+Groupby
+  Variable [ Name=idDBLP ]
+  :=
+  Variable [ Name=idDBLP ]
+  Variable [ Name=idCSX ]
+  :=
+  Variable [ Name=idCSX ]
+  Variable [ Name=sim ]
+  :=
+  Variable [ Name=sim ]
+  With
+  Variable [ Name=sim ]
+  Variable [ Name=tokensCSX ]
+  Variable [ Name=lenCSX ]
+  Variable [ Name=tokensUnrankedCSX ]
+  Variable [ Name=idCSX ]
+  Variable [ Name=tokensDBLP ]
+  Variable [ Name=lenDBLP ]
+  Variable [ Name=tokensUnrankedDBLP ]
+  Variable [ Name=idDBLP ]
+  Variable [ Name=paperDBLP ]
+  Variable [ Name=prefixTokenDBLP ]
+  Variable [ Name=prefixTokenCSX ]
+  Variable [ Name=paperCSX ]
+
+Orderby
+  Variable [ Name=idDBLP ]
+  ASC
+  Variable [ Name=idCSX ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.ast
new file mode 100644
index 0000000..35c6120
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_1/dblp-csx-3_1.3.ast
@@ -0,0 +1,358 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=paper ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        FunctionCall fuzzyjoin.len@1[
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+        ]
+        Variable [ Name=tokensDBLP ]
+        FunctionCall fuzzyjoin.len@1[
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+        ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+      Variable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+      Variable [ Name=sim ]
+      :=
+      Variable [ Name=sim ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.ast
new file mode 100644
index 0000000..4b67ba9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_2/dblp-csx-3_2.3.ast
@@ -0,0 +1,372 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        FunctionCall fuzzyjoin.len@1[
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+        ]
+        Variable [ Name=tokensDBLP ]
+        FunctionCall fuzzyjoin.len@1[
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+        ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+      Variable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+      Variable [ Name=sim ]
+      :=
+      Variable [ Name=sim ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.ast
new file mode 100644
index 0000000..635bea5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_3/dblp-csx-3_3.3.ast
@@ -0,0 +1,383 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        FunctionCall fuzzyjoin.len@1[
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+        ]
+        Variable [ Name=tokensDBLP ]
+        FunctionCall fuzzyjoin.len@1[
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+        ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      Variable [ Name=sim ]
+      :=
+      Variable [ Name=sim ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.ast
new file mode 100644
index 0000000..f7d802a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_4/dblp-csx-3_4.3.ast
@@ -0,0 +1,384 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedDBLP ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedDBLP ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedCSX ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedCSX ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=tokensUnrankedCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        FunctionCall fuzzyjoin.len@1[
+          Variable [ Name=tokensUnrankedDBLP ]
+        ]
+        Variable [ Name=tokensDBLP ]
+        FunctionCall fuzzyjoin.len@1[
+          Variable [ Name=tokensUnrankedCSX ]
+        ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      Variable [ Name=sim ]
+      :=
+      Variable [ Name=sim ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=tokensUnrankedCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=tokensUnrankedDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..ae3194f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.1/dblp-csx-3_5.3.ast
@@ -0,0 +1,392 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedDBLP ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenDBLP ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedDBLP ]
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedDBLP ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGrouped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGrouped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGrouped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedCSX ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenCSX ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedCSX ]
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedCSX ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGrouped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGrouped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=lenCSX ]
+              Variable [ Name=tokensUnrankedCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGrouped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenDBLP ]
+        Variable [ Name=tokensDBLP ]
+        Variable [ Name=lenCSX ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=lenCSX ]
+      Variable [ Name=tokensUnrankedCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=lenDBLP ]
+      Variable [ Name=tokensUnrankedDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..ae3194f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.2/dblp-csx-3_5.3.ast
@@ -0,0 +1,392 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedDBLP ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenDBLP ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedDBLP ]
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedDBLP ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGrouped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGrouped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGrouped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedCSX ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenCSX ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedCSX ]
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedCSX ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGrouped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGrouped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=lenCSX ]
+              Variable [ Name=tokensUnrankedCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGrouped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenDBLP ]
+        Variable [ Name=tokensDBLP ]
+        Variable [ Name=lenCSX ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=lenCSX ]
+      Variable [ Name=tokensUnrankedCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=lenDBLP ]
+      Variable [ Name=tokensUnrankedDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..ae3194f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3.1/dblp-csx-3_5.3.ast
@@ -0,0 +1,392 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedDBLP ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenDBLP ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedDBLP ]
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedDBLP ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGrouped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGrouped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGrouped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedCSX ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenCSX ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedCSX ]
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedCSX ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGrouped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGrouped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=lenCSX ]
+              Variable [ Name=tokensUnrankedCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGrouped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenDBLP ]
+        Variable [ Name=tokensDBLP ]
+        Variable [ Name=lenCSX ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=lenCSX ]
+      Variable [ Name=tokensUnrankedCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=lenDBLP ]
+      Variable [ Name=tokensUnrankedDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..10e93a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.3/dblp-csx-3_5.3.ast
@@ -0,0 +1,395 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedDBLP ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenDBLP ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedDBLP ]
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedDBLP ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedCSX ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenCSX ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedCSX ]
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedCSX ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=lenCSX ]
+              Variable [ Name=tokensUnrankedCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenDBLP ]
+        Variable [ Name=tokensDBLP ]
+        Variable [ Name=lenCSX ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      Variable [ Name=sim ]
+      :=
+      Variable [ Name=sim ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=lenCSX ]
+      Variable [ Name=tokensUnrankedCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=lenDBLP ]
+      Variable [ Name=tokensUnrankedDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..20d2c82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4.1/dblp-csx-3_5.3.ast
@@ -0,0 +1,437 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=paperDBLP
+    ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=id
+        ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        FieldAccessor [
+          Variable [ Name=ridpair ]
+          Field=idCSX
+        ]
+      )
+      (
+        LiteralExpr [STRING] [paperDBLP]
+        :
+        Variable [ Name=paperDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        FieldAccessor [
+          Variable [ Name=ridpair ]
+          Field=sim
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [idDBLP]
+            :
+            Variable [ Name=idDBLP ]
+          )
+          (
+            LiteralExpr [STRING] [idCSX]
+            :
+            Variable [ Name=idCSX ]
+          )
+          (
+            LiteralExpr [STRING] [sim]
+            :
+            IndexAccessor [
+              Variable [ Name=sim ]
+              Index:               Variable [ Name=sim ]
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paperDBLP ]
+,
+          FunctionCall fuzzyjoin.subset-collection@3[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+            LiteralExpr [LONG] [0]
+            FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+              FunctionCall fuzzyjoin.len@1[
+                FunctionCall Metadata.dataset@1[
+                  LiteralExpr [STRING] [tokensDBLP]
+                ]
+              ]
+              LiteralExpr [FLOAT] [0.5]
+            ]
+          ]
+          AS
+          Variable [ Name=prefixTokenDBLP ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [CSX]
+          ]
+          AS
+          Variable [ Name=paperCSX ]
+,
+          FunctionCall fuzzyjoin.subset-collection@3[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+            LiteralExpr [LONG] [0]
+            FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+              FunctionCall fuzzyjoin.len@1[
+                FunctionCall Metadata.dataset@1[
+                  LiteralExpr [STRING] [tokensCSX]
+                ]
+              ]
+              LiteralExpr [FLOAT] [0.5]
+            ]
+          ]
+          AS
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        LetVariable [ Name=idDBLP ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paperDBLP ]
+            Field=id
+          ]
+        LetVariable [ Name=tokensUnrankedDBLP ]
+          :=
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+        LetVariable [ Name=lenDBLP ]
+          :=
+          FunctionCall fuzzyjoin.len@1[
+            Variable [ Name=tokensUnrankedDBLP ]
+          ]
+        LetVariable [ Name=tokensDBLP ]
+          :=
+          (
+            SELECT ELEMENT [
+            Variable [ Name=i ]
+            ]
+            FROM [              Variable [ Name=tokensUnrankedDBLP ]
+              AS
+              Variable [ Name=tokenUnranked ]
+,
+              (
+                SELECT ELEMENT [
+                Variable [ Name=tokenGrouped ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [DBLP]
+                  ]
+                  AS
+                  Variable [ Name=paper ]
+,
+                  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                    FieldAccessor [
+                      Variable [ Name=paper ]
+                      Field=title
+                    ]
+                  ]
+                  AS
+                  Variable [ Name=token ]
+                ]
+                LetVariable [ Name=id ]
+                  :=
+                  FieldAccessor [
+                    Variable [ Name=paper ]
+                    Field=id
+                  ]
+                Groupby
+                  Variable [ Name=tokenGrouped ]
+                  :=
+                  Variable [ Name=token ]
+                  With
+                  Variable [ Name=id ]
+                  Variable [ Name=paper ]
+                  Variable [ Name=token ]
+                  Variable [ Name=tokenUnranked ]
+                  Variable [ Name=tokensDBLP ]
+                  Variable [ Name=lenDBLP ]
+                  Variable [ Name=tokensUnrankedDBLP ]
+                  Variable [ Name=idDBLP ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=prefixTokenDBLP ]
+                  Variable [ Name=prefixTokenCSX ]
+                  Variable [ Name=paperCSX ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=paperCSX ]
+
+                Orderby
+                  FunctionCall fuzzyjoin.count@1[
+                    Variable [ Name=id ]
+                  ]
+                  ASC
+                  Variable [ Name=tokenGrouped ]
+                  ASC
+
+              )
+              AS
+              Variable [ Name=tokenRanked ]
+              AT
+              Variable [ Name=i ]
+            ]
+            Where
+              OperatorExpr [
+                Variable [ Name=tokenUnranked ]
+                =
+                Variable [ Name=tokenRanked ]
+              ]
+            Orderby
+              Variable [ Name=i ]
+              ASC
+
+          )
+        LetVariable [ Name=idCSX ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paperCSX ]
+            Field=id
+          ]
+        LetVariable [ Name=tokensUnrankedCSX ]
+          :=
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+        LetVariable [ Name=lenCSX ]
+          :=
+          FunctionCall fuzzyjoin.len@1[
+            Variable [ Name=tokensUnrankedCSX ]
+          ]
+        LetVariable [ Name=tokensCSX ]
+          :=
+          (
+            SELECT ELEMENT [
+            Variable [ Name=i ]
+            ]
+            FROM [              Variable [ Name=tokensUnrankedCSX ]
+              AS
+              Variable [ Name=tokenUnranked ]
+,
+              (
+                SELECT ELEMENT [
+                Variable [ Name=tokenGrouped ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [DBLP]
+                  ]
+                  AS
+                  Variable [ Name=paper ]
+,
+                  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                    FieldAccessor [
+                      Variable [ Name=paper ]
+                      Field=title
+                    ]
+                  ]
+                  AS
+                  Variable [ Name=token ]
+                ]
+                LetVariable [ Name=id ]
+                  :=
+                  FieldAccessor [
+                    Variable [ Name=paper ]
+                    Field=id
+                  ]
+                Groupby
+                  Variable [ Name=tokenGrouped ]
+                  :=
+                  Variable [ Name=token ]
+                  With
+                  Variable [ Name=id ]
+                  Variable [ Name=paper ]
+                  Variable [ Name=token ]
+                  Variable [ Name=tokenUnranked ]
+                  Variable [ Name=tokensCSX ]
+                  Variable [ Name=lenCSX ]
+                  Variable [ Name=tokensUnrankedCSX ]
+                  Variable [ Name=idCSX ]
+                  Variable [ Name=tokensDBLP ]
+                  Variable [ Name=lenDBLP ]
+                  Variable [ Name=tokensUnrankedDBLP ]
+                  Variable [ Name=idDBLP ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=prefixTokenDBLP ]
+                  Variable [ Name=prefixTokenCSX ]
+                  Variable [ Name=paperCSX ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=paperCSX ]
+
+                Orderby
+                  FunctionCall fuzzyjoin.count@1[
+                    Variable [ Name=id ]
+                  ]
+                  ASC
+                  Variable [ Name=tokenGrouped ]
+                  ASC
+
+              )
+              AS
+              Variable [ Name=tokenRanked ]
+              AT
+              Variable [ Name=i ]
+            ]
+            Where
+              OperatorExpr [
+                Variable [ Name=tokenUnranked ]
+                =
+                Variable [ Name=tokenRanked ]
+              ]
+            Orderby
+              Variable [ Name=i ]
+              ASC
+
+          )
+        LetVariable [ Name=sim ]
+          :=
+          FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+            Variable [ Name=lenDBLP ]
+            Variable [ Name=tokensDBLP ]
+            Variable [ Name=lenCSX ]
+            Variable [ Name=tokensCSX ]
+            Variable [ Name=prefixTokenDBLP ]
+            LiteralExpr [FLOAT] [0.5]
+          ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              Variable [ Name=prefixTokenDBLP ]
+              =
+              Variable [ Name=prefixTokenCSX ]
+            ]
+            and
+            OperatorExpr [
+              Variable [ Name=sim ]
+              >=
+              LiteralExpr [FLOAT] [0.5]
+            ]
+          ]
+        Groupby
+          Variable [ Name=idDBLP ]
+          :=
+          Variable [ Name=idDBLP ]
+          Variable [ Name=idCSX ]
+          :=
+          Variable [ Name=idCSX ]
+          With
+          Variable [ Name=sim ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=paperCSX ]
+
+      )
+      AS
+      Variable [ Name=ridpair ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=ridpair ]
+          Field=idDBLP
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=id
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=paperDBLPridpair ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=idCSX
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=id
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLPridpair ]
+    Field=idDBLP
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperDBLPridpair ]
+    Field=idCSX
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..8cb40fd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5.4/dblp-csx-3_5.3.ast
@@ -0,0 +1,440 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=paperDBLP
+    ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=id
+        ]
+      )
+      (
+        LiteralExpr [STRING] [paperDBLP]
+        :
+        Variable [ Name=paperDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        FieldAccessor [
+          Variable [ Name=ridpair ]
+          Field=idCSX
+        ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        FieldAccessor [
+          Variable [ Name=ridpair ]
+          Field=sim
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [idDBLP]
+            :
+            Variable [ Name=idDBLP ]
+          )
+          (
+            LiteralExpr [STRING] [idCSX]
+            :
+            Variable [ Name=idCSX ]
+          )
+          (
+            LiteralExpr [STRING] [sim]
+            :
+            IndexAccessor [
+              Variable [ Name=sim ]
+              Index:               Variable [ Name=sim ]
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [DBLP]
+          ]
+          AS
+          Variable [ Name=paperDBLP ]
+,
+          FunctionCall fuzzyjoin.subset-collection@3[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+            LiteralExpr [LONG] [0]
+            FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+              FunctionCall fuzzyjoin.len@1[
+                FunctionCall Metadata.dataset@1[
+                  LiteralExpr [STRING] [tokensDBLP]
+                ]
+              ]
+              LiteralExpr [FLOAT] [0.5]
+            ]
+          ]
+          AS
+          Variable [ Name=prefixTokenDBLP ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [CSX]
+          ]
+          AS
+          Variable [ Name=paperCSX ]
+,
+          FunctionCall fuzzyjoin.subset-collection@3[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+            LiteralExpr [LONG] [0]
+            FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+              FunctionCall fuzzyjoin.len@1[
+                FunctionCall Metadata.dataset@1[
+                  LiteralExpr [STRING] [tokensCSX]
+                ]
+              ]
+              LiteralExpr [FLOAT] [0.5]
+            ]
+          ]
+          AS
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        LetVariable [ Name=idDBLP ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paperDBLP ]
+            Field=id
+          ]
+        LetVariable [ Name=tokensUnrankedDBLP ]
+          :=
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperDBLP ]
+              Field=title
+            ]
+          ]
+        LetVariable [ Name=lenDBLP ]
+          :=
+          FunctionCall fuzzyjoin.len@1[
+            Variable [ Name=tokensUnrankedDBLP ]
+          ]
+        LetVariable [ Name=tokensDBLP ]
+          :=
+          (
+            SELECT ELEMENT [
+            Variable [ Name=i ]
+            ]
+            FROM [              Variable [ Name=tokensUnrankedDBLP ]
+              AS
+              Variable [ Name=tokenUnranked ]
+,
+              (
+                SELECT ELEMENT [
+                Variable [ Name=tokenGrouped ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [DBLP]
+                  ]
+                  AS
+                  Variable [ Name=paper ]
+,
+                  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                    FieldAccessor [
+                      Variable [ Name=paper ]
+                      Field=title
+                    ]
+                  ]
+                  AS
+                  Variable [ Name=token ]
+                ]
+                LetVariable [ Name=id ]
+                  :=
+                  FieldAccessor [
+                    Variable [ Name=paper ]
+                    Field=id
+                  ]
+                Groupby
+                  Variable [ Name=tokenGrouped ]
+                  :=
+                  Variable [ Name=token ]
+                  With
+                  Variable [ Name=id ]
+                  Variable [ Name=paper ]
+                  Variable [ Name=token ]
+                  Variable [ Name=tokenUnranked ]
+                  Variable [ Name=tokensDBLP ]
+                  Variable [ Name=lenDBLP ]
+                  Variable [ Name=tokensUnrankedDBLP ]
+                  Variable [ Name=idDBLP ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=prefixTokenDBLP ]
+                  Variable [ Name=prefixTokenCSX ]
+                  Variable [ Name=paperCSX ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=paperCSX ]
+
+                Orderby
+                  FunctionCall fuzzyjoin.count@1[
+                    Variable [ Name=id ]
+                  ]
+                  ASC
+                  Variable [ Name=tokenGrouped ]
+                  ASC
+
+              )
+              AS
+              Variable [ Name=tokenRanked ]
+              AT
+              Variable [ Name=i ]
+            ]
+            Where
+              OperatorExpr [
+                Variable [ Name=tokenUnranked ]
+                =
+                Variable [ Name=tokenRanked ]
+              ]
+            Orderby
+              Variable [ Name=i ]
+              ASC
+
+          )
+        LetVariable [ Name=idCSX ]
+          :=
+          FieldAccessor [
+            Variable [ Name=paperCSX ]
+            Field=id
+          ]
+        LetVariable [ Name=tokensUnrankedCSX ]
+          :=
+          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+            FieldAccessor [
+              Variable [ Name=paperCSX ]
+              Field=title
+            ]
+          ]
+        LetVariable [ Name=lenCSX ]
+          :=
+          FunctionCall fuzzyjoin.len@1[
+            Variable [ Name=tokensUnrankedCSX ]
+          ]
+        LetVariable [ Name=tokensCSX ]
+          :=
+          (
+            SELECT ELEMENT [
+            Variable [ Name=i ]
+            ]
+            FROM [              Variable [ Name=tokensUnrankedCSX ]
+              AS
+              Variable [ Name=tokenUnranked ]
+,
+              (
+                SELECT ELEMENT [
+                Variable [ Name=tokenGrouped ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [DBLP]
+                  ]
+                  AS
+                  Variable [ Name=paper ]
+,
+                  FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                    FieldAccessor [
+                      Variable [ Name=paper ]
+                      Field=title
+                    ]
+                  ]
+                  AS
+                  Variable [ Name=token ]
+                ]
+                LetVariable [ Name=id ]
+                  :=
+                  FieldAccessor [
+                    Variable [ Name=paper ]
+                    Field=id
+                  ]
+                Groupby
+                  Variable [ Name=tokenGrouped ]
+                  :=
+                  Variable [ Name=token ]
+                  With
+                  Variable [ Name=id ]
+                  Variable [ Name=paper ]
+                  Variable [ Name=token ]
+                  Variable [ Name=tokenUnranked ]
+                  Variable [ Name=tokensCSX ]
+                  Variable [ Name=lenCSX ]
+                  Variable [ Name=tokensUnrankedCSX ]
+                  Variable [ Name=idCSX ]
+                  Variable [ Name=tokensDBLP ]
+                  Variable [ Name=lenDBLP ]
+                  Variable [ Name=tokensUnrankedDBLP ]
+                  Variable [ Name=idDBLP ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=prefixTokenDBLP ]
+                  Variable [ Name=prefixTokenCSX ]
+                  Variable [ Name=paperCSX ]
+                  Variable [ Name=paperDBLP ]
+                  Variable [ Name=paperCSX ]
+
+                Orderby
+                  FunctionCall fuzzyjoin.count@1[
+                    Variable [ Name=id ]
+                  ]
+                  ASC
+                  Variable [ Name=tokenGrouped ]
+                  ASC
+
+              )
+              AS
+              Variable [ Name=tokenRanked ]
+              AT
+              Variable [ Name=i ]
+            ]
+            Where
+              OperatorExpr [
+                Variable [ Name=tokenUnranked ]
+                =
+                Variable [ Name=tokenRanked ]
+              ]
+            Orderby
+              Variable [ Name=i ]
+              ASC
+
+          )
+        LetVariable [ Name=sim ]
+          :=
+          FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+            Variable [ Name=lenDBLP ]
+            Variable [ Name=tokensDBLP ]
+            Variable [ Name=lenCSX ]
+            Variable [ Name=tokensCSX ]
+            Variable [ Name=prefixTokenDBLP ]
+            LiteralExpr [FLOAT] [0.5]
+          ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              Variable [ Name=prefixTokenDBLP ]
+              =
+              Variable [ Name=prefixTokenCSX ]
+            ]
+            and
+            OperatorExpr [
+              Variable [ Name=sim ]
+              >=
+              LiteralExpr [FLOAT] [0.5]
+            ]
+          ]
+        Groupby
+          Variable [ Name=idDBLP ]
+          :=
+          Variable [ Name=idDBLP ]
+          Variable [ Name=idCSX ]
+          :=
+          Variable [ Name=idCSX ]
+          With
+          Variable [ Name=sim ]
+          Variable [ Name=tokensCSX ]
+          Variable [ Name=lenCSX ]
+          Variable [ Name=tokensUnrankedCSX ]
+          Variable [ Name=idCSX ]
+          Variable [ Name=tokensDBLP ]
+          Variable [ Name=lenDBLP ]
+          Variable [ Name=tokensUnrankedDBLP ]
+          Variable [ Name=idDBLP ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=prefixTokenDBLP ]
+          Variable [ Name=prefixTokenCSX ]
+          Variable [ Name=paperCSX ]
+          Variable [ Name=paperDBLP ]
+          Variable [ Name=paperCSX ]
+
+      )
+      AS
+      Variable [ Name=ridpair ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=ridpair ]
+          Field=idDBLP
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=id
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=paperDBLPridpair ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=idCSX
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=paperCSX ]
+      Field=id
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=paperDBLPridpair ]
+      Field=paperDBLP
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperDBLPridpair ]
+    Field=idCSX
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.ast
new file mode 100644
index 0000000..10e93a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-3_5/dblp-csx-3_5.3.ast
@@ -0,0 +1,395 @@
+DataverseUse fuzzyjoin
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=paperDBLP ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=paperCSX ]
+  )
+  (
+    LiteralExpr [STRING] [sim]
+    :
+    FieldAccessor [
+      Variable [ Name=ridpair ]
+      Field=sim
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [idDBLP]
+        :
+        Variable [ Name=idDBLP ]
+      )
+      (
+        LiteralExpr [STRING] [idCSX]
+        :
+        Variable [ Name=idCSX ]
+      )
+      (
+        LiteralExpr [STRING] [sim]
+        :
+        IndexAccessor [
+          Variable [ Name=sim ]
+          Index:           Variable [ Name=sim ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [DBLP]
+      ]
+      AS
+      Variable [ Name=paperDBLP ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensDBLP]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensDBLP]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenDBLP ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [CSX]
+      ]
+      AS
+      Variable [ Name=paperCSX ]
+,
+      FunctionCall fuzzyjoin.subset-collection@3[
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [tokensCSX]
+        ]
+        LiteralExpr [LONG] [0]
+        FunctionCall fuzzyjoin.prefix-len-jaccard@2[
+          FunctionCall fuzzyjoin.len@1[
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [tokensCSX]
+            ]
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+      AS
+      Variable [ Name=prefixTokenCSX ]
+    ]
+    LetVariable [ Name=idDBLP ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedDBLP ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperDBLP ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenDBLP ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedDBLP ]
+      ]
+    LetVariable [ Name=tokensDBLP ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedDBLP ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=idCSX ]
+      :=
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    LetVariable [ Name=tokensUnrankedCSX ]
+      :=
+      FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=paperCSX ]
+          Field=title
+        ]
+      ]
+    LetVariable [ Name=lenCSX ]
+      :=
+      FunctionCall fuzzyjoin.len@1[
+        Variable [ Name=tokensUnrankedCSX ]
+      ]
+    LetVariable [ Name=tokensCSX ]
+      :=
+      (
+        SELECT ELEMENT [
+        Variable [ Name=i ]
+        ]
+        FROM [          Variable [ Name=tokensUnrankedCSX ]
+          AS
+          Variable [ Name=tokenUnranked ]
+,
+          (
+            SELECT ELEMENT [
+            Variable [ Name=tokenGroupped ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [DBLP]
+              ]
+              AS
+              Variable [ Name=paper ]
+,
+              FunctionCall fuzzyjoin.counthashed-word-tokens@1[
+                FieldAccessor [
+                  Variable [ Name=paper ]
+                  Field=title
+                ]
+              ]
+              AS
+              Variable [ Name=token ]
+            ]
+            LetVariable [ Name=id ]
+              :=
+              FieldAccessor [
+                Variable [ Name=paper ]
+                Field=id
+              ]
+            Groupby
+              Variable [ Name=tokenGroupped ]
+              :=
+              Variable [ Name=token ]
+              With
+              Variable [ Name=id ]
+              Variable [ Name=paper ]
+              Variable [ Name=token ]
+              Variable [ Name=tokenUnranked ]
+              Variable [ Name=tokensCSX ]
+              Variable [ Name=lenCSX ]
+              Variable [ Name=tokensUnrankedCSX ]
+              Variable [ Name=idCSX ]
+              Variable [ Name=tokensDBLP ]
+              Variable [ Name=lenDBLP ]
+              Variable [ Name=tokensUnrankedDBLP ]
+              Variable [ Name=idDBLP ]
+              Variable [ Name=paperDBLP ]
+              Variable [ Name=prefixTokenDBLP ]
+              Variable [ Name=prefixTokenCSX ]
+              Variable [ Name=paperCSX ]
+
+            Orderby
+              FunctionCall fuzzyjoin.count@1[
+                Variable [ Name=id ]
+              ]
+              ASC
+              Variable [ Name=tokenGroupped ]
+              ASC
+
+          )
+          AS
+          Variable [ Name=tokenRanked ]
+          AT
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            Variable [ Name=tokenUnranked ]
+            =
+            Variable [ Name=tokenRanked ]
+          ]
+        Orderby
+          Variable [ Name=i ]
+          ASC
+
+      )
+    LetVariable [ Name=sim ]
+      :=
+      FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
+        Variable [ Name=lenDBLP ]
+        Variable [ Name=tokensDBLP ]
+        Variable [ Name=lenCSX ]
+        Variable [ Name=tokensCSX ]
+        Variable [ Name=prefixTokenDBLP ]
+        LiteralExpr [FLOAT] [0.5]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=prefixTokenDBLP ]
+          =
+          Variable [ Name=prefixTokenCSX ]
+        ]
+        and
+        OperatorExpr [
+          Variable [ Name=sim ]
+          >=
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      ]
+    Groupby
+      Variable [ Name=idDBLP ]
+      :=
+      Variable [ Name=idDBLP ]
+      Variable [ Name=idCSX ]
+      :=
+      Variable [ Name=idCSX ]
+      Variable [ Name=sim ]
+      :=
+      Variable [ Name=sim ]
+      With
+      Variable [ Name=sim ]
+      Variable [ Name=tokensCSX ]
+      Variable [ Name=lenCSX ]
+      Variable [ Name=tokensUnrankedCSX ]
+      Variable [ Name=idCSX ]
+      Variable [ Name=tokensDBLP ]
+      Variable [ Name=lenDBLP ]
+      Variable [ Name=tokensUnrankedDBLP ]
+      Variable [ Name=idDBLP ]
+      Variable [ Name=paperDBLP ]
+      Variable [ Name=prefixTokenDBLP ]
+      Variable [ Name=prefixTokenCSX ]
+      Variable [ Name=paperCSX ]
+
+  )
+  AS
+  Variable [ Name=ridpair ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paperDBLP ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=paperCSX ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idDBLP
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperDBLP ]
+        Field=id
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=ridpair ]
+        Field=idCSX
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=paperCSX ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paperDBLP ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=paperCSX ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.3.ast
new file mode 100644
index 0000000..a9a458c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_1/dblp-csx-aqlplus_1.3.ast
@@ -0,0 +1,57 @@
+DataverseUse fuzzyjoin
+Set simthreshold=.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=i ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=j ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=i ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=j ]
+]
+Where
+  OperatorExpr [
+    FunctionCall fuzzyjoin.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall fuzzyjoin.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=j ]
+        Field=title
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=j ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.3.ast
new file mode 100644
index 0000000..f77792b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_2/dblp-csx-aqlplus_2.3.ast
@@ -0,0 +1,57 @@
+DataverseUse fuzzyjoin
+Set simthreshold=.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=dblp ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=csx ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=csx ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp ]
+]
+Where
+  OperatorExpr [
+    FunctionCall fuzzyjoin.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=dblp ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall fuzzyjoin.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=csx ]
+        Field=title
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=dblp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=csx ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.3.ast
new file mode 100644
index 0000000..f9a8e32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-aqlplus_3/dblp-csx-aqlplus_3.3.ast
@@ -0,0 +1,57 @@
+DataverseUse fuzzyjoin
+Set simthreshold=.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=dblp ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=csx ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=csx ]
+]
+Where
+  OperatorExpr [
+    FunctionCall fuzzyjoin.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=csx ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall fuzzyjoin.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=dblp ]
+        Field=title
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=dblp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=csx ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.1.ast
new file mode 100644
index 0000000..b88d658
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.1.ast
@@ -0,0 +1,21 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  open RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.3.ast
new file mode 100644
index 0000000..7fd0cb6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-csx-dblp-aqlplus_1/dblp-csx-dblp-aqlplus_1.3.ast
@@ -0,0 +1,91 @@
+DataverseUse fuzzyjoin
+Set simthreshold=.5f
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dblp]
+    :
+    Variable [ Name=dblp ]
+  )
+  (
+    LiteralExpr [STRING] [csx]
+    :
+    Variable [ Name=csx ]
+  )
+  (
+    LiteralExpr [STRING] [dblp2]
+    :
+    Variable [ Name=dblp2 ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=csx ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=dblp2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall fuzzyjoin.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=dblp ]
+          Field=title
+        ]
+      ]
+      ~=
+      FunctionCall fuzzyjoin.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=csx ]
+          Field=title
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall fuzzyjoin.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=csx ]
+          Field=authors
+        ]
+      ]
+      ~=
+      FunctionCall fuzzyjoin.word-tokens@1[
+        FieldAccessor [
+          Variable [ Name=dblp2 ]
+          Field=authors
+        ]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=dblp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=csx ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dblp2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.1.ast
new file mode 100644
index 0000000..3d67eb1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.1.ast
@@ -0,0 +1,11 @@
+DataverseUse fuzzyjoin
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.3.ast
new file mode 100644
index 0000000..3d402f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/dblp-lookup_1/dblp-lookup_1.3.ast
@@ -0,0 +1,20 @@
+DataverseUse fuzzyjoin
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+    =
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.1.ast
new file mode 100644
index 0000000..7ad7cb2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.1.ast
@@ -0,0 +1,7 @@
+DataverseUse TinySocial
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.3.ast
new file mode 100644
index 0000000..04c2dfa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/fuzzyjoin/opentype/opentype.3.ast
@@ -0,0 +1,77 @@
+DataverseUse TinySocial
+Set simfunction=jaccard
+Set simthreshold=0.3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    Variable [ Name=t ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=referred-topics
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=referred-topics
+            ]
+            ~=
+            FieldAccessor [
+              Variable [ Name=t ]
+              Field=referred-topics
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_02/hdfs_02.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_03/hdfs_03.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/hdfs_shortcircuit/hdfs_shortcircuit.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hdfs/issue_245_hdfs/issue_245_hdfs.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_5/issue_251_dataset_hint_5.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_6/issue_251_dataset_hint_6.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/hints/issue_251_dataset_hint_7/issue_251_dataset_hint_7.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ast
new file mode 100644
index 0000000..1f77585
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int32,
+    statuses_count : int32,
+    name : string,
+    followers_count : int32
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : string,
+    sender-location : point,
+    send-time : datetime,
+    forward-from : int64,
+    retweet-from : int64,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl ResultType [
+  open RecordType {
+    vertexid : int64,
+    rank : double
+  }
+]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl results(ResultType) partitioned by [[vertexid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.ast
new file mode 100644
index 0000000..cada9fa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=tm ]
+  Field=tweetid
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=tu ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=tm ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [results]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=vertexid
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=tm ]
+        Field=tweetid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=tm ]
+        Field=user
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=tu ]
+        Field=screen-name
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=tm ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ast
new file mode 100644
index 0000000..8e9a28e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Orders(OrderType) partitioned by [[oid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.3.ast
new file mode 100644
index 0000000..44c462c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-primary-equi-join/btree-primary-equi-join.3.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cid]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [oid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=oid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=cid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=oid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.4.ast
new file mode 100644
index 0000000..e5857d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_01/btree-secondary-equi-join_01.4.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.4.ast
new file mode 100644
index 0000000..e5857d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_02/btree-secondary-equi-join_02.4.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.4.ast
new file mode 100644
index 0000000..e5857d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/btree-secondary-equi-join_03/btree-secondary-equi-join_03.4.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
new file mode 100644
index 0000000..7690f58
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData1(MyRecord) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
new file mode 100644
index 0000000..ccd4ff4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [apt]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bp]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=point
+      ]
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=point
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      !=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
new file mode 100644
index 0000000..3d2f941
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
new file mode 100644
index 0000000..d3b6da5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
new file mode 100644
index 0000000..3d2f941
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
new file mode 100644
index 0000000..54e08f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
@@ -0,0 +1,111 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ast
new file mode 100644
index 0000000..3d2f941
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.ast
new file mode 100644
index 0000000..af29f31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=referred-topics
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=referred-topics
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.similarity-jaccard-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=referred-topics
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=referred-topics
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
new file mode 100644
index 0000000..3d2f941
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
new file mode 100644
index 0000000..a0c5e3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
new file mode 100644
index 0000000..3d2f941
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
new file mode 100644
index 0000000..317564b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
new file mode 100644
index 0000000..3d2f941
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
new file mode 100644
index 0000000..13d31f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
new file mode 100644
index 0000000..8181f54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
new file mode 100644
index 0000000..b02e5b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Mattocks]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Micco]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Vangieson]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
new file mode 100644
index 0000000..8181f54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
new file mode 100644
index 0000000..03d433e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Isa]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
new file mode 100644
index 0000000..55154f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
@@ -0,0 +1,15 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
new file mode 100644
index 0000000..51e1c4c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
@@ -0,0 +1,110 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderstatus
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=o_orderstatus
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [20]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderstatus
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=o_orderstatus
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ast
new file mode 100644
index 0000000..49377bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.ast
new file mode 100644
index 0000000..9fa8d85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.ast
new file mode 100644
index 0000000..72cf10d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : string,
+    idx : string,
+    no-idx : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast
new file mode 100644
index 0000000..3686366
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=id
+      ]
+      =
+      LiteralExpr [STRING] [one]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=id
+      ]
+      =
+      LiteralExpr [STRING] [two]
+    ]
+    or
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=x ]
+        Field=id
+      ]
+      =
+      LiteralExpr [STRING] [two]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
new file mode 100644
index 0000000..00a8321
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
new file mode 100644
index 0000000..8ce7812
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
new file mode 100644
index 0000000..3d36aa6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast
new file mode 100644
index 0000000..8a83757
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
new file mode 100644
index 0000000..64b85b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
new file mode 100644
index 0000000..d1319d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ast
new file mode 100644
index 0000000..6069087
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.ast
new file mode 100644
index 0000000..dedb9b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ast
new file mode 100644
index 0000000..6069087
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.ast
new file mode 100644
index 0000000..9f22ba3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ast
new file mode 100644
index 0000000..6069087
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.ast
new file mode 100644
index 0000000..0cde310
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ast
new file mode 100644
index 0000000..50026d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.ast
new file mode 100644
index 0000000..98914ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=interests
+    ]
+    UnorderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [databases]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
new file mode 100644
index 0000000..00a8321
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
new file mode 100644
index 0000000..996effe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ast
new file mode 100644
index 0000000..55154f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ast
@@ -0,0 +1,15 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.ast
new file mode 100644
index 0000000..dcce0d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.ast
@@ -0,0 +1,55 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
new file mode 100644
index 0000000..bb5ab8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
@@ -0,0 +1,15 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
new file mode 100644
index 0000000..dcce0d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
@@ -0,0 +1,55 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ast
new file mode 100644
index 0000000..55154f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ast
@@ -0,0 +1,15 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  open RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.ast
new file mode 100644
index 0000000..8160020
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.ast
@@ -0,0 +1,44 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.1.ast
new file mode 100644
index 0000000..bb5ab8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.1.ast
@@ -0,0 +1,15 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.4.ast
new file mode 100644
index 0000000..8160020
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/orders-index-custkey/orders-index-custkey.4.ast
@@ -0,0 +1,44 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.1.ast
new file mode 100644
index 0000000..fd1a872
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  open RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.4.ast
new file mode 100644
index 0000000..120fe07
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search-open/range-search-open.4.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      >
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.4.ast
new file mode 100644
index 0000000..120fe07
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/range-search/range-search.4.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      >
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ast
new file mode 100644
index 0000000..a706d77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.ast
new file mode 100644
index 0000000..21d3e25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-circle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [5.0]
+        LiteralExpr [DOUBLE] [5.0]
+      ]
+      LiteralExpr [DOUBLE] [0.5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..b16a7f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point?,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..fe2fa6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ast
new file mode 100644
index 0000000..52cfcd1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.ast
new file mode 100644
index 0000000..fe2fa6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
new file mode 100644
index 0000000..a706d77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
new file mode 100644
index 0000000..fe2fa6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
new file mode 100644
index 0000000..228ff50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
new file mode 100644
index 0000000..fb57288
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
@@ -0,0 +1,85 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=name
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=name
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.1.ast
new file mode 100644
index 0000000..228ff50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.4.ast
new file mode 100644
index 0000000..9a1a1ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-edit-distance/ngram-edit-distance.4.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=name
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=name
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=name
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
new file mode 100644
index 0000000..e7c997a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
@@ -0,0 +1,94 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.ast
new file mode 100644
index 0000000..bc3861b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ngram-jaccard/ngram-jaccard.4.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.1.ast
new file mode 100644
index 0000000..fb3b754
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.ast
new file mode 100644
index 0000000..f00848c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance-inline/olist-edit-distance-inline.4.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.1.ast
new file mode 100644
index 0000000..fb3b754
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.ast
new file mode 100644
index 0000000..2cb6af9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-edit-distance/olist-edit-distance.4.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.1.ast
new file mode 100644
index 0000000..c30181f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.ast
new file mode 100644
index 0000000..5809dea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard-inline/olist-jaccard-inline.4.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.1.ast
new file mode 100644
index 0000000..c30181f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.ast
new file mode 100644
index 0000000..1b1f7d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/olist-jaccard/olist-jaccard.4.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.1.ast
new file mode 100644
index 0000000..175823d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.ast
new file mode 100644
index 0000000..5809dea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard-inline/ulist-jaccard-inline.4.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.1.ast
new file mode 100644
index 0000000..175823d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int32,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int32,
+    name : string,
+    age : int32?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int32?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.ast
new file mode 100644
index 0000000..1b1f7d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/ulist-jaccard/ulist-jaccard.4.ast
@@ -0,0 +1,98 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.1.ast
new file mode 100644
index 0000000..875d93c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int32,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int32,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.ast
new file mode 100644
index 0000000..e670ce9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard-inline/word-jaccard-inline.4.ast
@@ -0,0 +1,90 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.ast
new file mode 100644
index 0000000..1acfc8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join-noeqjoin/word-jaccard/word-jaccard.4.ast
@@ -0,0 +1,80 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
new file mode 100644
index 0000000..228ff50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
new file mode 100644
index 0000000..6ad6d9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=name
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=name
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.1.ast
new file mode 100644
index 0000000..228ff50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.4.ast
new file mode 100644
index 0000000..e9fb1bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-edit-distance/ngram-edit-distance.4.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=name
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=name
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
new file mode 100644
index 0000000..ef28532
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.4.ast
new file mode 100644
index 0000000..371a565
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ngram-jaccard/ngram-jaccard.4.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.1.ast
new file mode 100644
index 0000000..228ff50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.4.ast
new file mode 100644
index 0000000..ed1da42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance-inline/olist-edit-distance-inline.4.ast
@@ -0,0 +1,101 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.1.ast
new file mode 100644
index 0000000..228ff50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.4.ast
new file mode 100644
index 0000000..e18a355
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-edit-distance/olist-edit-distance.4.ast
@@ -0,0 +1,91 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.1.ast
new file mode 100644
index 0000000..4ef816e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.4.ast
new file mode 100644
index 0000000..5218e0e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard-inline/olist-jaccard-inline.4.ast
@@ -0,0 +1,101 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.1.ast
new file mode 100644
index 0000000..4ef816e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.4.ast
new file mode 100644
index 0000000..7b9e57f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/olist-jaccard/olist-jaccard.4.ast
@@ -0,0 +1,91 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.1.ast
new file mode 100644
index 0000000..b9e0d82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.4.ast
new file mode 100644
index 0000000..5218e0e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard-inline/ulist-jaccard-inline.4.ast
@@ -0,0 +1,101 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=interests
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=interests
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.1.ast
new file mode 100644
index 0000000..b9e0d82
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.4.ast
new file mode 100644
index 0000000..7b9e57f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/ulist-jaccard/ulist-jaccard.4.ast
@@ -0,0 +1,91 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.9]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.len@1[
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=interests
+        ]
+      ]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.4.ast
new file mode 100644
index 0000000..74ae0a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard-inline/word-jaccard-inline.4.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.4.ast
new file mode 100644
index 0000000..1fc8979
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/inverted-index-join/word-jaccard/word-jaccard.4.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/json/int01/int01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/json/int01/int01.1.ast
new file mode 100644
index 0000000..8d10786
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/json/int01/int01.1.ast
@@ -0,0 +1,7 @@
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  LiteralExpr [LONG] [1]
+  LiteralExpr [LONG] [2]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.3.ast
new file mode 100644
index 0000000..57f2c39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285-2/query_issue285-2.3.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bids]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [CSX]
+        ]
+        AS
+        Variable [ Name=b ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=authors
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=authors
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=id
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [10]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.3.ast
new file mode 100644
index 0000000..ed0638e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue285/query_issue285.3.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bids]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [CSX]
+        ]
+        AS
+        Variable [ Name=b ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=authors
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=authors
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=id
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.1.ast
new file mode 100644
index 0000000..573a985
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.3.ast
new file mode 100644
index 0000000..3c6cea7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue658/query_issue658.3.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bids]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [CSX]
+        ]
+        AS
+        Variable [ Name=b ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=authors
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=authors
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=title
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=title
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=id
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.1.ast
new file mode 100644
index 0000000..15d43df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl sType [
+  closed RecordType {
+    b : int64
+  }
+]
+DatasetDecl s(sType) partitioned by [[b]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.3.ast
new file mode 100644
index 0000000..6f7bde6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849-2/query_issue849-2.3.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [x]
+    :
+    Variable [ Name=x ]
+  )
+  (
+    LiteralExpr [STRING] [y]
+    :
+    Variable [ Name=y ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [s]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=z ]
+      Field=c
+    ]
+    ]
+    FROM [      UnorderedListConstructor [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [a]
+            :
+            LiteralExpr [LONG] [1]
+          )
+          (
+            LiteralExpr [STRING] [c]
+            :
+            LiteralExpr [LONG] [1]
+          )
+        ]
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [a]
+            :
+            LiteralExpr [LONG] [2]
+          )
+          (
+            LiteralExpr [STRING] [c]
+            :
+            LiteralExpr [LONG] [2]
+          )
+        ]
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [a]
+            :
+            LiteralExpr [LONG] [1]
+          )
+          (
+            LiteralExpr [STRING] [c]
+            :
+            LiteralExpr [NULL]
+          )
+        ]
+      ]
+      AS
+      Variable [ Name=z ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=b
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=z ]
+          Field=a
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.1.ast
new file mode 100644
index 0000000..15d43df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl sType [
+  closed RecordType {
+    b : int64
+  }
+]
+DatasetDecl s(sType) partitioned by [[b]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.3.ast
new file mode 100644
index 0000000..19f3d09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/leftouterjoin/query_issue849/query_issue849.3.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [x]
+    :
+    Variable [ Name=x ]
+  )
+  (
+    LiteralExpr [STRING] [y]
+    :
+    Variable [ Name=y ]
+  )
+]
+]
+FROM [  UnorderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [a]
+        :
+        LiteralExpr [LONG] [1]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [a]
+        :
+        LiteralExpr [LONG] [2]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=z ]
+      Field=b
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [s]
+      ]
+      AS
+      Variable [ Name=z ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=a
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=z ]
+          Field=b
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.3.ast
new file mode 100644
index 0000000..b96b43b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/any-collection-member_01/any-collection-member_01.3.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+Query:
+IndexAccessor [
+  UnorderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [1]
+  ]
+  Index: ANY
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.3.ast
new file mode 100644
index 0000000..f414383
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_01/get-item_01.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+IndexAccessor [
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+  ]
+  Index:   OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.3.ast
new file mode 100644
index 0000000..f414383
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/get-item_02/get-item_02.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+IndexAccessor [
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+  ]
+  Index:   OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.3.ast
new file mode 100644
index 0000000..b485e15
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_01/len_01.3.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.len@1[
+    OrderedListConstructor [
+    ]
+  ]
+  FunctionCall test.len@1[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+  FunctionCall test.len@1[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+  ]
+  FunctionCall test.len@1[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+  ]
+  FunctionCall test.len@1[
+    UnorderedListConstructor [
+    ]
+  ]
+  FunctionCall test.len@1[
+    UnorderedListConstructor [
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+  FunctionCall test.len@1[
+    UnorderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+  ]
+  FunctionCall test.len@1[
+    UnorderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.3.ast
new file mode 100644
index 0000000..f23296e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/len_null_01/len_null_01.3.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [len1]
+    :
+    FunctionCall test.len@1[
+      OrderedListConstructor [
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [len2]
+    :
+    LiteralExpr [NULL]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.3.ast
new file mode 100644
index 0000000..ae2e0f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_01/listify_01.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+  ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.3.ast
new file mode 100644
index 0000000..f11aab2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_02/listify_02.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [foo]
+    LiteralExpr [STRING] [bar]
+  ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast
new file mode 100644
index 0000000..81cb2a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/listify_03/listify_03.3.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.min@1[
+  Variable [ Name=y ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+LetVariable [ Name=y ]
+  :=
+  (
+    SELECT ELEMENT [
+    FunctionCall test.min@1[
+      Variable [ Name=i ]
+    ]
+    ]
+    FROM [      OrderedListConstructor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+          LiteralExpr [LONG] [2]
+          LiteralExpr [LONG] [3]
+        ]
+        OrderedListConstructor [
+          LiteralExpr [LONG] [10]
+          LiteralExpr [LONG] [20]
+          LiteralExpr [LONG] [30]
+        ]
+        OrderedListConstructor [
+          NEGATIVE LiteralExpr [LONG] [2]
+          NEGATIVE LiteralExpr [LONG] [5]
+          LiteralExpr [LONG] [0]
+        ]
+      ]
+      AS
+      Variable [ Name=i ]
+    ]
+  )
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.3.ast
new file mode 100644
index 0000000..684eeac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_01/ordered-list-constructor_01.3.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  LiteralExpr [STRING] [foo]
+  LiteralExpr [STRING] [bar]
+  LiteralExpr [STRING] [foobar]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.3.ast
new file mode 100644
index 0000000..e86c812
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_02/ordered-list-constructor_02.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  OrderedListConstructor [
+    LiteralExpr [STRING] [foo]
+    LiteralExpr [STRING] [bar]
+  ]
+  OrderedListConstructor [
+    LiteralExpr [STRING] [foobar]
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.3.ast
new file mode 100644
index 0000000..7cdb7c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/ordered-list-constructor_03/ordered-list-constructor_03.3.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  LiteralExpr [NULL]
+  LiteralExpr [NULL]
+  LiteralExpr [NULL]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/query-issue428/query-issue428.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.3.ast
new file mode 100644
index 0000000..53e2019
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/scan-collection_01/scan-collection_01.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=u ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+  ]
+  AS
+  Variable [ Name=u ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.3.ast
new file mode 100644
index 0000000..485ce93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_01/unordered-list-constructor_01.3.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+UnorderedListConstructor [
+  LiteralExpr [STRING] [foo]
+  LiteralExpr [STRING] [bar]
+  LiteralExpr [STRING] [foobar]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.3.ast
new file mode 100644
index 0000000..577ce23
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_02/unordered-list-constructor_02.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+UnorderedListConstructor [
+  UnorderedListConstructor [
+    LiteralExpr [STRING] [foo]
+  ]
+  UnorderedListConstructor [
+    LiteralExpr [STRING] [bar]
+    LiteralExpr [STRING] [foobar]
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.3.ast
new file mode 100644
index 0000000..72ba604
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/list/unordered-list-constructor_03/unordered-list-constructor_03.3.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+UnorderedListConstructor [
+  LiteralExpr [NULL]
+  LiteralExpr [NULL]
+  LiteralExpr [NULL]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_bianry.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_bianry.1.ast
new file mode 100644
index 0000000..65c1322
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_bianry.1.ast
@@ -0,0 +1,7 @@
+DataverseUse temp
+TypeDecl test [
+  open RecordType {
+    ba : binary
+  }
+]
+DatasetDecl testds(test) partitioned by [[ba]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_binary.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_binary.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_binary.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_binary.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_binary.3.ast
new file mode 100644
index 0000000..dfdb7a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/adm_binary/adm_binary.3.ast
@@ -0,0 +1,11 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.1.ast
new file mode 100644
index 0000000..5b45c85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.1.ast
@@ -0,0 +1,12 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float?,
+    double : double?,
+    date : string?,
+    time : string?,
+    datetime : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.3.ast
new file mode 100644
index 0000000..b884844
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_01/csv_01.3.ast
@@ -0,0 +1,97 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=double
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=date
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-after]
+    :
+    FunctionCall temp.date@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=date
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=time
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-after]
+    :
+    FunctionCall temp.time@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=time
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=datetime
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-after]
+    :
+    FunctionCall temp.datetime@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=datetime
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.1.ast
new file mode 100644
index 0000000..992b4f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.1.ast
@@ -0,0 +1,12 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float?,
+    double : double?,
+    date : string,
+    time : string,
+    datetime : string
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.3.ast
new file mode 100644
index 0000000..482a28e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_02/csv_02.3.ast
@@ -0,0 +1,67 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=double
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-string]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=date
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-string]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=time
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-string]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=datetime
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.1.ast
new file mode 100644
index 0000000..027bf47
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.1.ast
@@ -0,0 +1,13 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float,
+    floatq : float?,
+    double : double,
+    doubleq : double?,
+    string : string,
+    stringq : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.3.ast
new file mode 100644
index 0000000..ac77c83
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_03/csv_03.3.ast
@@ -0,0 +1,75 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [floatq]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=floatq
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=double
+    ]
+  )
+  (
+    LiteralExpr [STRING] [doubleq]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=doubleq
+    ]
+  )
+  (
+    LiteralExpr [STRING] [string]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=string
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringq]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringq
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.1.ast
new file mode 100644
index 0000000..f99b9f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.1.ast
@@ -0,0 +1,10 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float,
+    stringa : string,
+    stringb : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.3.ast
new file mode 100644
index 0000000..8fd7d90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_04/csv_04.3.ast
@@ -0,0 +1,51 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringa]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringa
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringb]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringb
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.1.ast
new file mode 100644
index 0000000..2176c7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.1.ast
@@ -0,0 +1,10 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int32,
+    float : float,
+    stringa : string,
+    stringb : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.3.ast
new file mode 100644
index 0000000..8fd7d90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_05/csv_05.3.ast
@@ -0,0 +1,51 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringa]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringa
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringb]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringb
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.1.ast
new file mode 100644
index 0000000..2176c7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.1.ast
@@ -0,0 +1,10 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int32,
+    float : float,
+    stringa : string,
+    stringb : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.3.ast
new file mode 100644
index 0000000..8fd7d90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_06/csv_06.3.ast
@@ -0,0 +1,51 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringa]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringa
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringb]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringb
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.1.ast
new file mode 100644
index 0000000..2176c7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.1.ast
@@ -0,0 +1,10 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int32,
+    float : float,
+    stringa : string,
+    stringb : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.3.ast
new file mode 100644
index 0000000..8fd7d90
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_07/csv_07.3.ast
@@ -0,0 +1,51 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringa]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringa
+    ]
+  )
+  (
+    LiteralExpr [STRING] [stringb]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=stringb
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.1.ast
new file mode 100644
index 0000000..5b45c85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.1.ast
@@ -0,0 +1,12 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float?,
+    double : double?,
+    date : string?,
+    time : string?,
+    datetime : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.3.ast
new file mode 100644
index 0000000..b884844
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_cr/csv_08.3.ast
@@ -0,0 +1,97 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=double
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=date
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-after]
+    :
+    FunctionCall temp.date@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=date
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=time
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-after]
+    :
+    FunctionCall temp.time@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=time
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=datetime
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-after]
+    :
+    FunctionCall temp.datetime@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=datetime
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.1.ast
new file mode 100644
index 0000000..5b45c85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.1.ast
@@ -0,0 +1,12 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float?,
+    double : double?,
+    date : string?,
+    time : string?,
+    datetime : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.3.ast
new file mode 100644
index 0000000..b884844
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_crlf/csv_08.3.ast
@@ -0,0 +1,97 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=double
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=date
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-after]
+    :
+    FunctionCall temp.date@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=date
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=time
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-after]
+    :
+    FunctionCall temp.time@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=time
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=datetime
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-after]
+    :
+    FunctionCall temp.datetime@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=datetime
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.1.ast
new file mode 100644
index 0000000..5b45c85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.1.ast
@@ -0,0 +1,12 @@
+DataverseUse temp
+TypeDecl test [
+  closed RecordType {
+    id : int64,
+    float : float?,
+    double : double?,
+    date : string?,
+    time : string?,
+    datetime : string?
+  }
+]
+DatasetDecl testds(test) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.2.ast
new file mode 100644
index 0000000..6004239
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.2.ast
@@ -0,0 +1 @@
+DataverseUse temp
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.3.ast
new file mode 100644
index 0000000..b884844
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/csv_08_header_lf/csv_08.3.ast
@@ -0,0 +1,97 @@
+DataverseUse temp
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [float]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=float
+    ]
+  )
+  (
+    LiteralExpr [STRING] [double]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=double
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=date
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-after]
+    :
+    FunctionCall temp.date@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=date
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=time
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-after]
+    :
+    FunctionCall temp.time@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=time
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-before]
+    :
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=datetime
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-after]
+    :
+    FunctionCall temp.datetime@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=datetime
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/duplicate-key-error/duplicate-key-error.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/duplicate-key-error/duplicate-key-error.1.ast
new file mode 100644
index 0000000..1f6677d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/duplicate-key-error/duplicate-key-error.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int32
+  }
+]
+DatasetDecl mydataset(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/duplicate-key-error/duplicate-key-error.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/duplicate-key-error/duplicate-key-error.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/duplicate-key-error/duplicate-key-error.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes-err-1/escapes-err-1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes-err-1/escapes-err-1.1.ast
new file mode 100644
index 0000000..738a731
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes-err-1/escapes-err-1.1.ast
@@ -0,0 +1,7 @@
+DataverseUse TestDataverse
+TypeDecl TestType [
+  open RecordType {
+    id : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes-err-1/escapes-err-1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes-err-1/escapes-err-1.2.ast
new file mode 100644
index 0000000..0da3f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes-err-1/escapes-err-1.2.ast
@@ -0,0 +1 @@
+DataverseUse TestDataverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.1.ast
new file mode 100644
index 0000000..738a731
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.1.ast
@@ -0,0 +1,7 @@
+DataverseUse TestDataverse
+TypeDecl TestType [
+  open RecordType {
+    id : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.2.ast
new file mode 100644
index 0000000..0da3f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.2.ast
@@ -0,0 +1 @@
+DataverseUse TestDataverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.3.ast
new file mode 100644
index 0000000..176ce1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes01/escapes01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse TestDataverse
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.1.ast
new file mode 100644
index 0000000..738a731
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.1.ast
@@ -0,0 +1,7 @@
+DataverseUse TestDataverse
+TypeDecl TestType [
+  open RecordType {
+    id : string
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.2.ast
new file mode 100644
index 0000000..0da3f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.2.ast
@@ -0,0 +1 @@
+DataverseUse TestDataverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.3.ast
new file mode 100644
index 0000000..176ce1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/escapes02/escapes02.3.ast
@@ -0,0 +1,18 @@
+DataverseUse TestDataverse
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.1.ast
new file mode 100644
index 0000000..c7bac21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int32,
+    age : int32,
+    name : string
+  }
+]
+DatasetDecl onektup(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.3.ast
new file mode 100644
index 0000000..db4fdc9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue14_query/issue14_query.3.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+Query:
+  SELECT ELEMENT [
+  Variable [ Name=l Id=0 ]
+  ]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [onektup] 
+  ]
+  Variable [ Name=l Id=0 ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.1.ast
new file mode 100644
index 0000000..da4fb64
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+DatasetDecl Customers(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.3.ast
new file mode 100644
index 0000000..323b20d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue289_query/issue289_query.3.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=l ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Customers]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue315_query/issue315_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue315_query/issue315_query.1.ast
new file mode 100644
index 0000000..c7bac21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue315_query/issue315_query.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int32,
+    age : int32,
+    name : string
+  }
+]
+DatasetDecl onektup(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue315_query/issue315_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue315_query/issue315_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue315_query/issue315_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ast
new file mode 100644
index 0000000..92722c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ast
@@ -0,0 +1,11 @@
+DataverseUse foo
+TypeDecl bartype [
+  open RecordType {
+    id : int32,
+    nest_rec :       open RecordType {
+        id : int32
+      }
+
+  }
+]
+DatasetDecl baz(bartype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.2.ast
new file mode 100644
index 0000000..d0f6490
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.2.ast
@@ -0,0 +1 @@
+DataverseUse foo
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue650_query/issue650_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue650_query/issue650_query.1.ast
new file mode 100644
index 0000000..7e05489
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue650_query/issue650_query.1.ast
@@ -0,0 +1,12 @@
+DataverseUse fuzzyjoin
+TypeDecl UserType [
+  open RecordType {
+    uid : int32,
+    name : string,
+    lottery_numbers : OrderedList [int32]
+,
+    interests : UnorderedList <string>
+
+  }
+]
+DatasetDecl Users(UserType) partitioned by [[uid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue650_query/issue650_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue650_query/issue650_query.2.ast
new file mode 100644
index 0000000..0b720ed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/issue650_query/issue650_query.2.ast
@@ -0,0 +1 @@
+DataverseUse fuzzyjoin
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.1.ast
new file mode 100644
index 0000000..ab8d5af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.1.ast
@@ -0,0 +1,37 @@
+DataverseUse TestDataverse
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    int8 : int8,
+    int16 : int16,
+    int32 : int32,
+    int64 : int64,
+    float : float,
+    double : double,
+    int8_u : UnorderedList <int8>
+?,
+    int8_o : OrderedList [int8]
+?,
+    int16_u : UnorderedList <int16>
+?,
+    int16_o : OrderedList [int16]
+?,
+    int32_u : UnorderedList <int32>
+?,
+    int32_o : OrderedList [int32]
+?,
+    int64_u : UnorderedList <int64>
+?,
+    int64_o : OrderedList [int64]
+?,
+    float_u : UnorderedList <float>
+?,
+    float_o : OrderedList [float]
+?,
+    double_u : UnorderedList <double>
+?,
+    double_o : OrderedList [double]
+?
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.2.ast
new file mode 100644
index 0000000..0da3f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.2.ast
@@ -0,0 +1 @@
+DataverseUse TestDataverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.3.ast
new file mode 100644
index 0000000..176ce1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/load/type_promotion_0/type_promotion_0.3.ast
@@ -0,0 +1,18 @@
+DataverseUse TestDataverse
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.1.ast
new file mode 100644
index 0000000..edfd2e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.1.ast
@@ -0,0 +1,21 @@
+DataverseUse TinySocial
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.3.ast
new file mode 100644
index 0000000..c0fdc765
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/materialization/assign-reuse/assign-reuse.3.ast
@@ -0,0 +1,130 @@
+DataverseUse TinySocial
+Query:
+LetVariable [ Name=lonelyusers ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=d ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=d ]
+    ]
+    Where
+      OperatorExpr [
+        FunctionCall TinySocial.count@1[
+          FieldAccessor [
+            Variable [ Name=d ]
+            Field=friend-ids
+          ]
+        ]
+        <
+        LiteralExpr [LONG] [2]
+      ]
+  )
+LetVariable [ Name=lonelyusers2 ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=d ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=d ]
+    ]
+    Where
+      OperatorExpr [
+        FunctionCall TinySocial.count@1[
+          FieldAccessor [
+            Variable [ Name=d ]
+            Field=friend-ids
+          ]
+        ]
+        <
+        LiteralExpr [LONG] [2]
+      ]
+  )
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user1]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=id
+        ]
+      )
+      (
+        LiteralExpr [STRING] [name]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=name
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [user2]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=l2 ]
+          Field=id
+        ]
+      )
+      (
+        LiteralExpr [STRING] [name]
+        :
+        FieldAccessor [
+          Variable [ Name=l2 ]
+          Field=name
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  Variable [ Name=lonelyusers ]
+  AS
+  Variable [ Name=l1 ]
+,
+  Variable [ Name=lonelyusers2 ]
+  AS
+  Variable [ Name=l2 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l1 ]
+      Field=id
+    ]
+    <
+    FieldAccessor [
+      Variable [ Name=l2 ]
+      Field=id
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l1 ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=l2 ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.3.ast
new file mode 100644
index 0000000..69b596c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/float_01/float_01.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=f ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [FLOAT] [1.0]
+    LiteralExpr [FLOAT] [1.0]
+    LiteralExpr [FLOAT] [1.1]
+    LiteralExpr [FLOAT] [1.1]
+    LiteralExpr [FLOAT] [0.1]
+    LiteralExpr [FLOAT] [0.1]
+  ]
+  AS
+  Variable [ Name=f ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.1.ast
new file mode 100644
index 0000000..1e091e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.1.ast
@@ -0,0 +1,24 @@
+DataverseUse DMLTest
+TypeDecl EmploymentType [
+  closed RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    id-copy : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    user-since-copy : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers1(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookUsers2(FacebookUserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.2.ast
new file mode 100644
index 0000000..45751a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.2.ast
@@ -0,0 +1 @@
+DataverseUse DMLTest
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.3.ast
new file mode 100644
index 0000000..45751a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.3.ast
@@ -0,0 +1 @@
+DataverseUse DMLTest
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.4.ast
new file mode 100644
index 0000000..fc3a08a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/flushtest/flushtest.4.ast
@@ -0,0 +1,11 @@
+DataverseUse DMLTest
+Query:
+SELECT ELEMENT [
+Variable [ Name=t ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers2]
+  ]
+  AS
+  Variable [ Name=t ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.1.ast
new file mode 100644
index 0000000..7124560
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.1.ast
@@ -0,0 +1,11 @@
+DataverseUse twitter
+TypeDecl Tweet [
+  open RecordType {
+    id : int64,
+    tweetid : int64,
+    loc : point,
+    time : datetime,
+    text : string
+  }
+]
+DatasetDecl TwitterData(Tweet)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.3.ast
new file mode 100644
index 0000000..d920145
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/groupby-orderby-count/groupby-orderby-count.3.ast
@@ -0,0 +1,55 @@
+DataverseUse twitter
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [word]
+    :
+    Variable [ Name=tok ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall twitter.count@1[
+      Variable [ Name=token ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterData]
+  ]
+  AS
+  Variable [ Name=t ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tokens]
+  ]
+  AS
+  Variable [ Name=token ]
+]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall twitter.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=text
+    ]
+  ]
+Groupby
+  Variable [ Name=tok ]
+  :=
+  Variable [ Name=token ]
+  With
+  Variable [ Name=tokens ]
+  Variable [ Name=t ]
+  Variable [ Name=token ]
+
+Orderby
+  FunctionCall twitter.count@1[
+    Variable [ Name=token ]
+  ]
+  DESC
+  Variable [ Name=tok ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.3.ast
new file mode 100644
index 0000000..2223305
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/ifthenelse_01/ifthenelse_01.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+IfExpr [
+  Condition:
+    OperatorExpr [
+      LiteralExpr [LONG] [2]
+      >
+      LiteralExpr [LONG] [1]
+    ]
+  Then:
+    LiteralExpr [LONG] [20]
+  Else:
+    LiteralExpr [LONG] [10]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.3.ast
new file mode 100644
index 0000000..8e60e20
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/is-null_01/is-null_01.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.is-null@1[
+    LiteralExpr [NULL]
+  ]
+  FunctionCall test.is-null@1[
+    LiteralExpr [LONG] [10]
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.1.ast
new file mode 100644
index 0000000..43fccff
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl UserType [
+  open RecordType {
+    uid : int64,
+    name : string,
+    lottery_numbers : OrderedList [int64]
+,
+    interests : UnorderedList <string>
+
+  }
+]
+TypeDecl VisitorType [
+  open RecordType {
+    vid : int64,
+    name : string,
+    lottery_numbers : OrderedList [int64]
+,
+    interests : UnorderedList <string>
+
+  }
+]
+DatasetDecl Users(UserType) partitioned by [[uid]]
+DatasetDecl Visitors(VisitorType) partitioned by [[vid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.3.ast
new file mode 100644
index 0000000..3c322fa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/nested-loop-join_01/nested-loop-join_01.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user]
+    :
+    Variable [ Name=user ]
+  )
+  (
+    LiteralExpr [STRING] [visitor]
+    :
+    Variable [ Name=visitor ]
+  )
+  (
+    LiteralExpr [STRING] [user-lottery_numbers-len]
+    :
+    FunctionCall test.len@1[
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=lottery_numbers
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [visitor-lottery_numbers-len]
+    :
+    FunctionCall test.len@1[
+      FieldAccessor [
+        Variable [ Name=visitor ]
+        Field=lottery_numbers
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Users]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Visitors]
+  ]
+  AS
+  Variable [ Name=visitor ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.len@1[
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=lottery_numbers
+      ]
+    ]
+    =
+    FunctionCall test.len@1[
+      FieldAccessor [
+        Variable [ Name=visitor ]
+        Field=lottery_numbers
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=uid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=visitor ]
+    Field=vid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.1.ast
new file mode 100644
index 0000000..01423bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name1 : string
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.3.ast
new file mode 100644
index 0000000..16bb849
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/partition-by-nonexistent-field/partition-by-nonexistent-field.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.1.ast
new file mode 100644
index 0000000..3535ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.3.ast
new file mode 100644
index 0000000..eb41e9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/prefix-search/prefix-search.3.ast
@@ -0,0 +1,55 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_linenumber]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_linenumber
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_l_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_orderkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      >=
+      LiteralExpr [LONG] [0]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.1.ast
new file mode 100644
index 0000000..21f0ce4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name : string
+  }
+]
+DatasetDecl t1(TestType) partitioned by [[name]]
+DatasetDecl t2(TestType) partitioned by [[name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.3.ast
new file mode 100644
index 0000000..59cf201
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/query_issue267/query_issue267.3.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t1]
+  ]
+  AS
+  Variable [ Name=l ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t2]
+  ]
+  AS
+  Variable [ Name=m ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.lowercase@1[
+        FieldAccessor [
+          Variable [ Name=m ]
+          Field=name
+        ]
+      ]
+      =
+      FunctionCall test.lowercase@1[
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=name
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FunctionCall test.string-length@1[
+        FieldAccessor [
+          Variable [ Name=m ]
+          Field=name
+        ]
+      ]
+      =
+      FunctionCall test.string-length@1[
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=name
+        ]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.3.ast
new file mode 100644
index 0000000..92440cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/stable_sort/stable_sort.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=i ]
+    Field=l_partkey
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.1.ast
new file mode 100644
index 0000000..edfd2e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.1.ast
@@ -0,0 +1,21 @@
+DataverseUse TinySocial
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.3.ast
new file mode 100644
index 0000000..9e8ab09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/string_eq_01/string_eq_01.3.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=alias
+    ]
+    =
+    LiteralExpr [STRING] [Isbel]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.3.ast
new file mode 100644
index 0000000..43d5ce0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/misc/year_01/year_01.3.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.get-year@1[
+  LiteralExpr [STRING] [1996-12-01]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ast
new file mode 100644
index 0000000..78ff882
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl LineItemTypetmp [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    nested : LineItemTypetmp
+  }
+]
+DatasetDecl LineItemtmp(LineItemTypetmp) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineItem(LineItemType) partitioned by [[nested, l_orderkey], [nested, l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.ast
new file mode 100644
index 0000000..2a1d058
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/compact-dataset-and-its-indexes/compact-dataset-and-its-indexes.5.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast
new file mode 100644
index 0000000..bae6bc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast
new file mode 100644
index 0000000..3322539
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=user
+      ]
+      Field=statuses_count
+    ]
+    <
+    LiteralExpr [LONG] [473]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.1.ast
new file mode 100644
index 0000000..22902dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl Schematmp [
+  closed RecordType {
+    unique1 : int64,
+    unique2 : int64,
+    two : int64,
+    four : int64,
+    ten : int64,
+    twenty : int64,
+    onePercent : int64,
+    tenPercent : int64,
+    twentyPercent : int64,
+    fiftyPercent : int64,
+    unique3 : int64,
+    evenOnePercent : int64,
+    oddOnePercent : int64,
+    stringu1 : string,
+    stringu2 : string,
+    string4 : string
+  }
+]
+TypeDecl Schema [
+  closed RecordType {
+    nested : Schematmp
+  }
+]
+DatasetDecl t1tmp(Schematmp) partitioned by [[unique2]]
+DatasetDecl t1(Schema) partitioned by [[nested, unique2]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.4.ast
new file mode 100644
index 0000000..3301a9a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/drop-index/drop-index.4.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=a ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t1]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=unique1
+      ]
+      >
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=stringu1
+      ]
+      =
+      LiteralExpr [STRING] [DGAAAAXXXXXXXXXXXXXXXXXXX]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ast
new file mode 100644
index 0000000..bae6bc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.ast
new file mode 100644
index 0000000..7fa9617
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-empty-dataset-with-index/insert-into-empty-dataset-with-index.3.ast
@@ -0,0 +1,37 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=name
+      ]
+      >=
+      LiteralExpr [STRING] [Nathan Giesen]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=statuses_count
+      ]
+      >
+      LiteralExpr [LONG] [164]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ast
new file mode 100644
index 0000000..bae6bc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.4.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.ast
new file mode 100644
index 0000000..beac285
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_01/insert-into-loaded-dataset-with-index_01.5.ast
@@ -0,0 +1,44 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=name
+      ]
+      =
+      LiteralExpr [STRING] [Nathan Giesen]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=statuses_count
+      ]
+      =
+      LiteralExpr [LONG] [473]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ast
new file mode 100644
index 0000000..bae6bc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.4.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.ast
new file mode 100644
index 0000000..f275f5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/insert-into-loaded-dataset-with-index_02/insert-into-loaded-dataset-with-index_02.5.ast
@@ -0,0 +1,37 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=name
+      ]
+      <
+      LiteralExpr [STRING] [Nathan Giesen]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=statuses_count
+      ]
+      <
+      LiteralExpr [LONG] [473]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.1.ast
new file mode 100644
index 0000000..fe958cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    user : TwitterUserType,
+    tweetid : int64,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.3.ast
new file mode 100644
index 0000000..a7e785e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-index/load-with-index.3.ast
@@ -0,0 +1,44 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=name
+      ]
+      <
+      LiteralExpr [STRING] [Nathan Giesen]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=statuses_count
+      ]
+      <
+      LiteralExpr [LONG] [473]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.1.ast
new file mode 100644
index 0000000..fe958cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    user : TwitterUserType,
+    tweetid : int64,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.3.ast
new file mode 100644
index 0000000..30e9f36
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-ngram-index/load-with-ngram-index.3.ast
@@ -0,0 +1,29 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  FunctionCall TinySocial.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=user
+      ]
+      Field=name
+    ]
+    LiteralExpr [STRING] [Nathan]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.1.ast
new file mode 100644
index 0000000..93b5182
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64,
+    sender-location : point?
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    user : TwitterUserType,
+    tweetid : int64,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.3.ast
new file mode 100644
index 0000000..959db3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-rtree-index/load-with-rtree-index.3.ast
@@ -0,0 +1,38 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  FunctionCall TinySocial.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=user
+      ]
+      Field=sender-location
+    ]
+    FunctionCall TinySocial.create-rectangle@2[
+      FunctionCall TinySocial.create-point@2[
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [0.0]
+      ]
+      FunctionCall TinySocial.create-point@2[
+        LiteralExpr [DOUBLE] [50.0]
+        LiteralExpr [DOUBLE] [80.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.1.ast
new file mode 100644
index 0000000..fe958cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.1.ast
@@ -0,0 +1,23 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    user : TwitterUserType,
+    tweetid : int64,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.3.ast
new file mode 100644
index 0000000..b3b9260
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/load-with-word-index/load-with-word-index.3.ast
@@ -0,0 +1,40 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall TinySocial.similarity-jaccard-check@3[
+    FunctionCall TinySocial.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=user
+        ]
+        Field=name
+      ]
+    ]
+    FunctionCall TinySocial.word-tokens@1[
+      LiteralExpr [STRING] [Nathan Giesen]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.1.ast
new file mode 100644
index 0000000..0c2f3dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.1.ast
@@ -0,0 +1,18 @@
+DataverseUse twitter
+TypeDecl TweetMessageType [
+  closed RecordType {
+    id : uuid,
+    message-text : string
+  }
+]
+TypeDecl nest [
+  closed RecordType {
+    nested : TweetMessageType
+  }
+]
+TypeDecl doublenest [
+  closed RecordType {
+    nested : nest
+  }
+]
+DatasetDecl doublenests(doublenest) partitioned by [[nested, nested, id]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.2.ast
new file mode 100644
index 0000000..a7feae7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.2.ast
@@ -0,0 +1 @@
+DataverseUse twitter
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.3.ast
new file mode 100644
index 0000000..1c078f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-insert/nested-uuid-insert.3.ast
@@ -0,0 +1,20 @@
+DataverseUse twitter
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=test ]
+      Field=nested
+    ]
+    Field=nested
+  ]
+  Field=message-text
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [doublenests]
+  ]
+  AS
+  Variable [ Name=test ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.1.ast
new file mode 100644
index 0000000..59e8148
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.1.ast
@@ -0,0 +1,24 @@
+DataverseUse twitter
+TypeDecl TwitterUserType [
+  open RecordType {
+    userid : uuid,
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    user : TwitterUserType,
+    tweetid : int64,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[user, userid]] [autogenerated]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.2.ast
new file mode 100644
index 0000000..a7feae7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.2.ast
@@ -0,0 +1 @@
+DataverseUse twitter
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.3.ast
new file mode 100644
index 0000000..29b491c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/nested-uuid-load/nested-uuid-load.3.ast
@@ -0,0 +1,38 @@
+DataverseUse twitter
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid]
+    :
+    FieldAccessor [
+      Variable [ Name=test ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [screen-name]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=test ]
+        Field=user
+      ]
+      Field=screen-name
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=test ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..af5c96f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..4e91616
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-btree-secondary-index-nullable/scan-delete-btree-secondary-index-nullable.5.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..f011ef5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index-nullable/scan-delete-inverted-index-ngram-secondary-index-nullable.5.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-ngram-secondary-index/scan-delete-inverted-index-ngram-secondary-index.5.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..f011ef5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..18c05a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index-nullable/scan-delete-inverted-index-word-secondary-index-nullable.5.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.ast
new file mode 100644
index 0000000..18c05a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-inverted-index-word-secondary-index/scan-delete-inverted-index-word-secondary-index.5.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..e6c73f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point?,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..46784ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index-nullable/scan-delete-rtree-secondary-index-nullable.5.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast
new file mode 100644
index 0000000..ff4d0d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast
new file mode 100644
index 0000000..46784ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..1b7413a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.1.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl CustomersMinitmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl CustomersMini(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..50b2522
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-btree-secondary-index-nullable/scan-insert-btree-secondary-index-nullable.5.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CustomersMini]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..f011ef5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index-nullable/scan-insert-inverted-index-ngram-secondary-index-nullable.5.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-ngram-secondary-index/scan-insert-inverted-index-ngram-secondary-index.5.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..f011ef5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string?,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..18c05a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index-nullable/scan-insert-inverted-index-word-secondary-index-nullable.5.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.ast
new file mode 100644
index 0000000..18c05a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-inverted-index-word-secondary-index/scan-insert-inverted-index-word-secondary-index.5.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..20dfc4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point?,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyMiniRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point?
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    nested : MyMiniRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..2b48718
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.3.ast
@@ -0,0 +1,2 @@
+DataverseUse test
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.ast
new file mode 100644
index 0000000..aac1fb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index-nullable/scan-insert-rtree-secondary-index-nullable.5.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast
new file mode 100644
index 0000000..1a6481c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyMiniRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    nested : MyMiniRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyMiniDatatmp(MyMiniRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast
new file mode 100644
index 0000000..aac1fb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index-dml/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/adm-format/adm-format.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
new file mode 100644
index 0000000..33b473e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
new file mode 100644
index 0000000..fa1c6b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
@@ -0,0 +1,129 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.1.ast
new file mode 100644
index 0000000..33b473e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.3.ast
new file mode 100644
index 0000000..75e1630
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/leftouterjoin/leftouterjoin.3.ast
@@ -0,0 +1,124 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.1.ast
new file mode 100644
index 0000000..3893877
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl MyRecordNested [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordNested
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.3.ast
new file mode 100644
index 0000000..85d9f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/external-indexing/rtree-index/rtree-index.3.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ast
new file mode 100644
index 0000000..aae35b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.1.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    cashBack : int64,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderTypetmp [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float,
+    items : OrderedList [int64]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[oid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, oid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.3.ast
new file mode 100644
index 0000000..7b8e706
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-primary-equi-join/btree-primary-equi-join.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [oid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=oid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=cid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=oid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast
new file mode 100644
index 0000000..14e0783
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast
new file mode 100644
index 0000000..0eb3809
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
new file mode 100644
index 0000000..4237b72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerNestedType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerNestedType
+  }
+]
+DatasetDecl Customerstmp(CustomerNestedType) partitioned by [[cid]]
+DatasetDecl Customers2tmp(CustomerNestedType) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
new file mode 100644
index 0000000..858596e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=name
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=name
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ast
new file mode 100644
index 0000000..4237b72
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerNestedType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerNestedType
+  }
+]
+DatasetDecl Customerstmp(CustomerNestedType) partitioned by [[cid]]
+DatasetDecl Customers2tmp(CustomerNestedType) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.ast
new file mode 100644
index 0000000..e72556b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=name
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=name
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
new file mode 100644
index 0000000..d01c1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+TypeDecl CSXNestedType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXNestedType
+  }
+]
+DatasetDecl DBLPtmp(DBLPNestedType) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXNestedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
new file mode 100644
index 0000000..c358727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ast
new file mode 100644
index 0000000..d01c1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+TypeDecl CSXNestedType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXNestedType
+  }
+]
+DatasetDecl DBLPtmp(DBLPNestedType) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXNestedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.ast
new file mode 100644
index 0000000..9008db8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
new file mode 100644
index 0000000..53b6ad0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyData1tmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData2tmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData1(MyRecord) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
new file mode 100644
index 0000000..3cdd4de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
@@ -0,0 +1,117 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [apt]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bp]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=point
+      ]
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=point
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      !=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ast
new file mode 100644
index 0000000..d01c1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+TypeDecl CSXNestedType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXNestedType
+  }
+]
+DatasetDecl DBLPtmp(DBLPNestedType) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXNestedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.ast
new file mode 100644
index 0000000..96bb7a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.ast
@@ -0,0 +1,107 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.1.ast
new file mode 100644
index 0000000..d01c1aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+TypeDecl CSXNestedType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXNestedType
+  }
+]
+DatasetDecl DBLPtmp(DBLPNestedType) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXNestedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.4.ast
new file mode 100644
index 0000000..4d58f03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-join/word-jaccard/word-jaccard.4.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
new file mode 100644
index 0000000..734aee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
new file mode 100644
index 0000000..75e1630
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
@@ -0,0 +1,124 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
new file mode 100644
index 0000000..734aee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
new file mode 100644
index 0000000..22e08c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
@@ -0,0 +1,144 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ast
new file mode 100644
index 0000000..734aee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.ast
new file mode 100644
index 0000000..e6de9dd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.ast
@@ -0,0 +1,156 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=referred-topics
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=referred-topics
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.similarity-jaccard-check@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=referred-topics
+          ]
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=referred-topics
+          ]
+          LiteralExpr [FLOAT] [0.5]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
new file mode 100644
index 0000000..734aee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
new file mode 100644
index 0000000..3079d43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
@@ -0,0 +1,156 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=nested
+          ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
new file mode 100644
index 0000000..734aee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
new file mode 100644
index 0000000..fa1c6b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
@@ -0,0 +1,129 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
new file mode 100644
index 0000000..734aee1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  closed RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
new file mode 100644
index 0000000..47049b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
@@ -0,0 +1,149 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
new file mode 100644
index 0000000..3cd0117
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl EmpTmp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Nested [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Emp [
+  closed RecordType {
+    nested : Nested
+  }
+]
+DatasetDecl employeeTmp(EmpTmp) partitioned by [[id]]
+DatasetDecl employee(Emp) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast
new file mode 100644
index 0000000..2918cae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=l ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Mattocks]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Micco]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Vangieson]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
new file mode 100644
index 0000000..3cd0117
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl EmpTmp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Nested [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Emp [
+  closed RecordType {
+    nested : Nested
+  }
+]
+DatasetDecl employeeTmp(EmpTmp) partitioned by [[id]]
+DatasetDecl employee(Emp) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
new file mode 100644
index 0000000..233c544
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=l ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Isa]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
new file mode 100644
index 0000000..b4e3463
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
@@ -0,0 +1,34 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  open RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl Nested [
+  open RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    nested : Nested
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
new file mode 100644
index 0000000..0219928
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
@@ -0,0 +1,146 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderstatus
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=nested
+      ]
+      Field=o_orderstatus
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [20]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o2 ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_orderstatus
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o2 ]
+          Field=nested
+        ]
+        Field=o_orderstatus
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ast
new file mode 100644
index 0000000..f653aba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.ast
new file mode 100644
index 0000000..4e91616
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/cust-index-age-nullable/cust-index-age-nullable.4.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [20]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
new file mode 100644
index 0000000..0ea40e8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+DatasetDecl DBLPtmp(DBLPNestedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
new file mode 100644
index 0000000..10557ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
new file mode 100644
index 0000000..e841a79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast
new file mode 100644
index 0000000..4ac8358
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPNestedType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPNestedType
+  }
+]
+DatasetDecl DBLPtmp(DBLPNestedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast
new file mode 100644
index 0000000..ab4ea4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
new file mode 100644
index 0000000..ccc037f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
new file mode 100644
index 0000000..fc953dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ast
new file mode 100644
index 0000000..ab35f38d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.ast
new file mode 100644
index 0000000..817393c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance-panic/inverted-index-olist-edit-distance-panic.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [3]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ast
new file mode 100644
index 0000000..ab35f38d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.ast
new file mode 100644
index 0000000..13c695b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-edit-distance/inverted-index-olist-edit-distance.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [walking]
+    ]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ast
new file mode 100644
index 0000000..ab35f38d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.ast
new file mode 100644
index 0000000..e3dc042
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-olist-jaccard/inverted-index-olist-jaccard.4.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    OrderedListConstructor [
+      LiteralExpr [STRING] [databases]
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ast
new file mode 100644
index 0000000..af5c96f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.1.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+TypeDecl AddressType [
+  closed RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerTypetmp [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerTypetmp
+  }
+]
+DatasetDecl Customerstmp(CustomerTypetmp) partitioned by [[cid]]
+DatasetDecl Customers(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.ast
new file mode 100644
index 0000000..8ff23a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-ulist-jaccard/inverted-index-ulist-jaccard.4.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=nested
+      ]
+      Field=interests
+    ]
+    UnorderedListConstructor [
+      LiteralExpr [STRING] [computers]
+      LiteralExpr [STRING] [wine]
+      LiteralExpr [STRING] [databases]
+    ]
+    LiteralExpr [FLOAT] [0.7]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
new file mode 100644
index 0000000..870359b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
new file mode 100644
index 0000000..18c05a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ast
new file mode 100644
index 0000000..619ed7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.1.ast
@@ -0,0 +1,21 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  open RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.ast
new file mode 100644
index 0000000..b788785
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive-open/orders-index-custkey-conjunctive-open.4.ast
@@ -0,0 +1,70 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
new file mode 100644
index 0000000..ce26480
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
@@ -0,0 +1,21 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
new file mode 100644
index 0000000..b788785
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
@@ -0,0 +1,70 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ast
new file mode 100644
index 0000000..ce26480
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.1.ast
@@ -0,0 +1,21 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.ast
new file mode 100644
index 0000000..9e1279f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey-open/orders-index-custkey-open.4.ast
@@ -0,0 +1,56 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.1.ast
new file mode 100644
index 0000000..ce26480
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.1.ast
@@ -0,0 +1,21 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderTypetmp
+  }
+]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.4.ast
new file mode 100644
index 0000000..9e1279f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/orders-index-custkey/orders-index-custkey.4.ast
@@ -0,0 +1,56 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.1.ast
new file mode 100644
index 0000000..86ee639
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl LineItemTypetmp [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    nested : LineItemTypetmp
+  }
+]
+DatasetDecl LineItemtmp(LineItemTypetmp) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineItem(LineItemType) partitioned by [[nested, l_orderkey], [nested, l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.4.ast
new file mode 100644
index 0000000..ba54bfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search-open/range-search-open.4.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=l_suppkey
+      ]
+      >
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.1.ast
new file mode 100644
index 0000000..86ee639
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl LineItemTypetmp [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    nested : LineItemTypetmp
+  }
+]
+DatasetDecl LineItemtmp(LineItemTypetmp) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineItem(LineItemType) partitioned by [[nested, l_orderkey], [nested, l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.4.ast
new file mode 100644
index 0000000..ba54bfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/range-search/range-search.4.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=l_suppkey
+      ]
+      >
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ast
new file mode 100644
index 0000000..e6c73f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point?,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.ast
new file mode 100644
index 0000000..85d9f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-nullable/rtree-secondary-index-nullable.4.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ast
new file mode 100644
index 0000000..38885f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle
+  }
+]
+TypeDecl MyRecord [
+  open RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.ast
new file mode 100644
index 0000000..85d9f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index-open/rtree-secondary-index-open.4.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
new file mode 100644
index 0000000..ff4d0d4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
new file mode 100644
index 0000000..85d9f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/adm-format/adm-format.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
new file mode 100644
index 0000000..ff2565a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
new file mode 100644
index 0000000..fa1c6b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
@@ -0,0 +1,129 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.1.ast
new file mode 100644
index 0000000..54cbf84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.1.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.3.ast
new file mode 100644
index 0000000..75e1630
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/leftouterjoin/leftouterjoin.3.ast
@@ -0,0 +1,124 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.1.ast
new file mode 100644
index 0000000..2b6baa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.1.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+TypeDecl MyRecordNested [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordNested
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.3.ast
new file mode 100644
index 0000000..85d9f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/external-indexing/rtree-index/rtree-index.3.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-closed/bottom-closed-top-closed.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-closed-top-open/bottom-closed-top-open.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-closed/bottom-open-top-closed.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/highly-open-highly-nested/bottom-open-top-open/bottom-open-top-open.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast
new file mode 100644
index 0000000..28b3640
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast
new file mode 100644
index 0000000..0eb3809
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    =
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
new file mode 100644
index 0000000..cb72bca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerOpenNestedType [
+  open RecordType {
+    cid : int64,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerNestedType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerNestedType
+  }
+]
+TypeDecl CustomerOpenType [
+  closed RecordType {
+    nested : CustomerOpenNestedType
+  }
+]
+DatasetDecl Customerstmp(CustomerOpenNestedType) partitioned by [[cid]]
+DatasetDecl Customers2tmp(CustomerNestedType) partitioned by [[cid]]
+DatasetDecl Customers(CustomerOpenType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
new file mode 100644
index 0000000..858596e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=name
+    ]
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=name
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ast
new file mode 100644
index 0000000..cb72bca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerOpenNestedType [
+  open RecordType {
+    cid : int64,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerNestedType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    nested : CustomerNestedType
+  }
+]
+TypeDecl CustomerOpenType [
+  closed RecordType {
+    nested : CustomerOpenNestedType
+  }
+]
+DatasetDecl Customerstmp(CustomerOpenNestedType) partitioned by [[cid]]
+DatasetDecl Customers2tmp(CustomerNestedType) partitioned by [[cid]]
+DatasetDecl Customers(CustomerOpenType) partitioned by [[nested, cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[nested, cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.4.ast
new file mode 100644
index 0000000..e72556b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-edit-distance/ngram-edit-distance.4.ast
@@ -0,0 +1,93 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=nested
+          ]
+          Field=name
+        ]
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=nested
+          ]
+          Field=name
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
new file mode 100644
index 0000000..9355547
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
new file mode 100644
index 0000000..c358727
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
@@ -0,0 +1,112 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.1.ast
new file mode 100644
index 0000000..9355547
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.4.ast
new file mode 100644
index 0000000..9008db8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/ngram-jaccard/ngram-jaccard.4.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
new file mode 100644
index 0000000..9d46c59
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordOpen
+  }
+]
+DatasetDecl MyData1tmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData2tmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData1(MyRecord) partitioned by [[nested, id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
new file mode 100644
index 0000000..3cdd4de
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
@@ -0,0 +1,117 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [apt]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bp]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=nested
+      ]
+      Field=point
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=point
+      ]
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=point
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      !=
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ast
new file mode 100644
index 0000000..9355547
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.4.ast
new file mode 100644
index 0000000..96bb7a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard-inline/word-jaccard-inline.4.ast
@@ -0,0 +1,107 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.1.ast
new file mode 100644
index 0000000..9355547
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.1.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXTypetmp [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    nested : CSXTypetmp
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl CSXtmp(CSXTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
+DatasetDecl CSX(CSXType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.4.ast
new file mode 100644
index 0000000..4d58f03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-join/word-jaccard/word-jaccard.4.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=a ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=b ]
+              Field=nested
+            ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=nested
+        ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=nested
+        ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
new file mode 100644
index 0000000..7f6b44f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
new file mode 100644
index 0000000..75e1630
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
@@ -0,0 +1,124 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=nested
+            ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
new file mode 100644
index 0000000..7f6b44f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
new file mode 100644
index 0000000..22e08c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
@@ -0,0 +1,144 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
new file mode 100644
index 0000000..fa3dadc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
new file mode 100644
index 0000000..c1b14f9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
@@ -0,0 +1,138 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesTmp]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
new file mode 100644
index 0000000..905ede6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
new file mode 100644
index 0000000..fa1c6b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
@@ -0,0 +1,129 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
new file mode 100644
index 0000000..905ede6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageNestedType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    nested : TweetMessageNestedType
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[nested, tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageNestedType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
new file mode 100644
index 0000000..47049b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
@@ -0,0 +1,149 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=nested
+            ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=t2 ]
+                Field=nested
+              ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=nested
+          ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=nested
+      ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=nested
+    ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
new file mode 100644
index 0000000..2604029
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+TypeDecl EmpTmp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Nested [
+  open RecordType {
+    id : int64,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Emp [
+  closed RecordType {
+    nested : Nested
+  }
+]
+DatasetDecl employeeTmp(EmpTmp) partitioned by [[id]]
+DatasetDecl employee(Emp) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast
new file mode 100644
index 0000000..2918cae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=l ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Mattocks]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Micco]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Vangieson]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
new file mode 100644
index 0000000..2604029
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+TypeDecl EmpTmp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Nested [
+  open RecordType {
+    id : int64,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl Emp [
+  closed RecordType {
+    nested : Nested
+  }
+]
+DatasetDecl employeeTmp(EmpTmp) partitioned by [[id]]
+DatasetDecl employee(Emp) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
new file mode 100644
index 0000000..233c544
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=l ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=nested
+        ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Isa]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
new file mode 100644
index 0000000..4f71d8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
@@ -0,0 +1,33 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl Nested [
+  open RecordType {
+    o_orderkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : Nested
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
new file mode 100644
index 0000000..0219928
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
@@ -0,0 +1,146 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderstatus
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus2]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=nested
+      ]
+      Field=o_orderstatus
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [20]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o2 ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_orderstatus
+      ]
+      <
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o2 ]
+          Field=nested
+        ]
+        Field=o_orderstatus
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
new file mode 100644
index 0000000..86490da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
new file mode 100644
index 0000000..c95d4b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPClosedType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPClosedType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
new file mode 100644
index 0000000..10557ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=nested
+      ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=paper ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
new file mode 100644
index 0000000..b7a99b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
new file mode 100644
index 0000000..e841a79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
new file mode 100644
index 0000000..b7a99b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
new file mode 100644
index 0000000..ccc037f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
new file mode 100644
index 0000000..86490da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
new file mode 100644
index 0000000..fc953dc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
new file mode 100644
index 0000000..86490da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
new file mode 100644
index 0000000..5b4ffed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
new file mode 100644
index 0000000..86490da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl DBLPTypetmp [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    nested : DBLPOpenType
+  }
+]
+DatasetDecl DBLPtmp(DBLPTypetmp) partitioned by [[id]]
+DatasetDecl DBLP(DBLPType) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
new file mode 100644
index 0000000..18c05a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=o ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
new file mode 100644
index 0000000..9ac5e4b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
@@ -0,0 +1,33 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderOpenType [
+  open RecordType {
+    o_orderkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderOpenType
+  }
+]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
new file mode 100644
index 0000000..b788785
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
@@ -0,0 +1,70 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=nested
+        ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.1.ast
new file mode 100644
index 0000000..9ac5e4b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.1.ast
@@ -0,0 +1,33 @@
+DataverseUse tpch
+TypeDecl OrderTypetmp [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderOpenType [
+  open RecordType {
+    o_orderkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    nested : OrderOpenType
+  }
+]
+DatasetDecl Orderstmp(OrderTypetmp) partitioned by [[o_orderkey]]
+DatasetDecl Orders(OrderType) partitioned by [[nested, o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.4.ast
new file mode 100644
index 0000000..9e1279f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/orders-index-custkey/orders-index-custkey.4.ast
@@ -0,0 +1,56 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.1.ast
new file mode 100644
index 0000000..703981f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.1.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+TypeDecl LineItemTypetmp [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemOpenType [
+  open RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemType [
+  closed RecordType {
+    nested : LineItemOpenType
+  }
+]
+DatasetDecl LineItemtmp(LineItemTypetmp) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineItem(LineItemType) partitioned by [[nested, l_orderkey], [nested, l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.4.ast
new file mode 100644
index 0000000..ba54bfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/range-search/range-search.4.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=c ]
+  Field=nested
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=nested
+        ]
+        Field=l_suppkey
+      ]
+      >
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=nested
+    ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
new file mode 100644
index 0000000..df19990
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl MyRecordtmp [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecord [
+  closed RecordType {
+    nested : MyRecordtmp
+  }
+]
+DatasetDecl MyDatatmp(MyRecordtmp) partitioned by [[id]]
+DatasetDecl MyData(MyRecord) partitioned by [[nested, id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
new file mode 100644
index 0000000..85d9f1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nested-open-index/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=nested
+      ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=nested
+    ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.1.ast
new file mode 100644
index 0000000..be24604
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.1.ast
@@ -0,0 +1,15 @@
+DataverseUse testdv2
+TypeDecl AddressType [
+  open RecordType {
+    street : string,
+    city : string
+  }
+]
+TypeDecl testtype [
+  open RecordType {
+    name : string,
+    id : string,
+    address : AddressType?
+  }
+]
+DatasetDecl testds(testtype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.3.ast
new file mode 100644
index 0000000..ecce0a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/nestrecords/nestrecord/nestrecord.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.3.ast
new file mode 100644
index 0000000..406f256
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs0/abs0.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.3.ast
new file mode 100644
index 0000000..71c5830
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs1/abs1.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-29]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [27]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.3.ast
new file mode 100644
index 0000000..0f65e75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs2/abs2.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.3.ast
new file mode 100644
index 0000000..91fa426
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs3/abs3.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast
new file mode 100644
index 0000000..a27798a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/abs4/abs4.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.abs@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.abs@1[
+      NEGATIVE LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.abs@1[
+      LiteralExpr [DOUBLE] [12.9]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.abs@1[
+      LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.3.ast
new file mode 100644
index 0000000..08a0267
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_double/add_double.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.3.ast
new file mode 100644
index 0000000..10928fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_float/add_float.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      +
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      +
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      +
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      +
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      +
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      +
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.3.ast
new file mode 100644
index 0000000..e086e33
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int16/add_int16.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      +
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      +
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      +
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      +
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      +
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      +
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.3.ast
new file mode 100644
index 0000000..374cc32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int32/add_int32.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      +
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      +
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      +
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      +
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      +
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      +
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.3.ast
new file mode 100644
index 0000000..9fff5e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int64/add_int64.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      +
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      +
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      +
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      +
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      +
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      +
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.3.ast
new file mode 100644
index 0000000..07cce2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/add_int8/add_int8.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      +
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      +
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      +
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      +
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      +
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      +
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      +
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.3.ast
new file mode 100644
index 0000000..310b481
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/caret0/caret0.3.ast
@@ -0,0 +1,30 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    OperatorExpr [
+      LiteralExpr [DOUBLE] [2.0]
+      ^
+      LiteralExpr [DOUBLE] [4096.0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c2]
+    :
+    OperatorExpr [
+      LiteralExpr [DOUBLE] [4096.0]
+      ^
+      LiteralExpr [DOUBLE] [2.0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c3]
+    :
+    OperatorExpr [
+      LiteralExpr [LONG] [3]
+      ^
+      LiteralExpr [LONG] [2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.3.ast
new file mode 100644
index 0000000..971b343
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling0/ceiling0.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.3.ast
new file mode 100644
index 0000000..5c82b7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling1/ceiling1.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-29]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [27]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.3.ast
new file mode 100644
index 0000000..94a56b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling2/ceiling2.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.3.ast
new file mode 100644
index 0000000..741ba0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling3/ceiling3.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast
new file mode 100644
index 0000000..8f0324f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/ceiling4/ceiling4.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.ceiling@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.ceiling@1[
+      NEGATIVE LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.ceiling@1[
+      LiteralExpr [DOUBLE] [12.9]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.ceiling@1[
+      LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.3.ast
new file mode 100644
index 0000000..4128270
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_double/divide_double.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.3.ast
new file mode 100644
index 0000000..9560a49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_float/divide_float.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      /
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      /
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      /
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      /
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      /
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      /
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.3.ast
new file mode 100644
index 0000000..b0cc853
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int16/divide_int16.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      /
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      /
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      /
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      /
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      /
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      /
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.3.ast
new file mode 100644
index 0000000..e0d9e56
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int32/divide_int32.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      /
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      /
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      /
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      /
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      /
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      /
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.3.ast
new file mode 100644
index 0000000..c042637
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int64/divide_int64.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      /
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      /
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      /
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      /
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      /
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      /
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.3.ast
new file mode 100644
index 0000000..940a9c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/divide_int8/divide_int8.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      /
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      /
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      /
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      /
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      /
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      /
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      /
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.3.ast
new file mode 100644
index 0000000..d6d9169
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor0/floor0.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.3.ast
new file mode 100644
index 0000000..8f18c92
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor1/floor1.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-29]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [27]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.3.ast
new file mode 100644
index 0000000..8ce77da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor2/floor2.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.3.ast
new file mode 100644
index 0000000..d08e452
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor3/floor3.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast
new file mode 100644
index 0000000..25b47d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/floor4/floor4.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.floor@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.floor@1[
+      NEGATIVE LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.floor@1[
+      LiteralExpr [DOUBLE] [12.9]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.floor@1[
+      LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.3.ast
new file mode 100644
index 0000000..ecb3c02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_double/multiply_double.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.3.ast
new file mode 100644
index 0000000..28ea27a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_float/multiply_float.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      *
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      *
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      *
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      *
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      *
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      *
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.3.ast
new file mode 100644
index 0000000..bb00a4e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int16/multiply_int16.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      *
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      *
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      *
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      *
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      *
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      *
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.3.ast
new file mode 100644
index 0000000..7a8df5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int32/multiply_int32.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      *
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      *
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      *
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      *
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      *
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      *
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.3.ast
new file mode 100644
index 0000000..60892b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int64/multiply_int64.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      *
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      *
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      *
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      *
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      *
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      *
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.3.ast
new file mode 100644
index 0000000..001f751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/query-issue355/query-issue355.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.3.ast
new file mode 100644
index 0000000..9c771d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even0/round-half-to-even0.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.3.ast
new file mode 100644
index 0000000..28d6297
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even1/round-half-to-even1.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-29]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [27]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.3.ast
new file mode 100644
index 0000000..6007940
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even2/round-half-to-even2.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.5]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-20.5]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.3.ast
new file mode 100644
index 0000000..811c63a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even20/round-half-to-even20.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [0]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.3.ast
new file mode 100644
index 0000000..b3d1598
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even21/round-half-to-even21.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-23]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-29]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-21]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [20]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [22]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [23]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [27]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.3.ast
new file mode 100644
index 0000000..0e2608e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even22/round-half-to-even22.3.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.555]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.322]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+      LiteralExpr [LONG] [3]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [INF]
+      ]
+      LiteralExpr [LONG] [4]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+      LiteralExpr [LONG] [5]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+      LiteralExpr [LONG] [6]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+      LiteralExpr [LONG] [0]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.3.ast
new file mode 100644
index 0000000..1797fdb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even23/round-half-to-even23.3.ast
@@ -0,0 +1,74 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.555]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.322]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+      LiteralExpr [LONG] [3]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [INF]
+      ]
+      LiteralExpr [LONG] [4]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+      LiteralExpr [LONG] [5]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+      LiteralExpr [LONG] [6]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+      LiteralExpr [LONG] [0]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast
new file mode 100644
index 0000000..c2d41d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even24/round-half-to-even24.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.015]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.025]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [3.567812E+3]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [4.7564E-3]
+      ]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.round-half-to-even@2[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [35612.25]
+      ]
+      NEGATIVE LiteralExpr [LONG] [2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.3.ast
new file mode 100644
index 0000000..3376733
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even3/round-half-to-even3.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.5]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-20.5]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.3.ast
new file mode 100644
index 0000000..1b4eb21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even4/round-half-to-even4.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [1.5]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [2.5]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast
new file mode 100644
index 0000000..ade34b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round-half-to-even5/round-half-to-even5.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round-half-to-even@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round-half-to-even@1[
+      NEGATIVE LiteralExpr [DOUBLE] [1.5]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round-half-to-even@1[
+      LiteralExpr [DOUBLE] [12.5]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round-half-to-even@1[
+      LiteralExpr [DOUBLE] [1.5]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.3.ast
new file mode 100644
index 0000000..f41a151
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round0/round0.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.3.ast
new file mode 100644
index 0000000..ae7b4ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round1/round1.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [-23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [-29]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [22]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [23]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f7]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [27]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.3.ast
new file mode 100644
index 0000000..c6fd56d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round2/round2.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.3.ast
new file mode 100644
index 0000000..6abd653
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round3/round3.3.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [d0]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [20.1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d1]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-20.56e-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d2]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [NaN]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d3]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d4]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-INF]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d5]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-0.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [d6]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [0.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast
new file mode 100644
index 0000000..e372fa9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/round4/round4.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f0]
+    :
+    FunctionCall test.round@1[
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [-20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.round@1[
+      NEGATIVE LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.round@1[
+      LiteralExpr [DOUBLE] [12.9]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.round@1[
+      LiteralExpr [DOUBLE] [1.11]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.3.ast
new file mode 100644
index 0000000..e99c5fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.3.ast
new file mode 100644
index 0000000..5b8b8d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.3.ast
new file mode 100644
index 0000000..868f368
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.3.ast
new file mode 100644
index 0000000..96a2352
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.3.ast
new file mode 100644
index 0000000..52ee8af
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.3.ast
new file mode 100644
index 0000000..fd0b1f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.3.ast
@@ -0,0 +1,100 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall test.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall test.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall test.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall test.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall test.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall test.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast
new file mode 100644
index 0000000..58c8e8b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_double_02/unary-minus_double_02.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [double1]
+    :
+    NEGATIVE FunctionCall test.double@1[
+  LiteralExpr [STRING] [-20.56e-30]
+]
+  )
+  (
+    LiteralExpr [STRING] [double2]
+    :
+    NEGATIVE FunctionCall test.double@1[
+  LiteralExpr [STRING] [NaN]
+]
+  )
+  (
+    LiteralExpr [STRING] [double3]
+    :
+    NEGATIVE FunctionCall test.double@1[
+  LiteralExpr [STRING] [INF]
+]
+  )
+  (
+    LiteralExpr [STRING] [double4]
+    :
+    NEGATIVE FunctionCall test.double@1[
+  LiteralExpr [STRING] [-INF]
+]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast
new file mode 100644
index 0000000..27fd67f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_float_02/unary-minus_float_02.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [float1]
+    :
+    NEGATIVE FunctionCall test.float@1[
+  LiteralExpr [STRING] [-80.20f]
+]
+  )
+  (
+    LiteralExpr [STRING] [float2]
+    :
+    NEGATIVE FunctionCall test.float@1[
+  LiteralExpr [STRING] [NaN]
+]
+  )
+  (
+    LiteralExpr [STRING] [float3]
+    :
+    NEGATIVE FunctionCall test.float@1[
+  LiteralExpr [STRING] [INF]
+]
+  )
+  (
+    LiteralExpr [STRING] [float4]
+    :
+    NEGATIVE FunctionCall test.float@1[
+  LiteralExpr [STRING] [-INF]
+]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast
new file mode 100644
index 0000000..682a20d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_int_02/unary-minus_int_02.3.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [int8]
+    :
+    NEGATIVE FunctionCall test.int8@1[
+  LiteralExpr [STRING] [+80]
+]
+  )
+  (
+    LiteralExpr [STRING] [int16]
+    :
+    NEGATIVE FunctionCall test.int16@1[
+  LiteralExpr [STRING] [160]
+]
+  )
+  (
+    LiteralExpr [STRING] [int32]
+    :
+    NEGATIVE FunctionCall test.int32@1[
+  LiteralExpr [STRING] [+320]
+]
+  )
+  (
+    LiteralExpr [STRING] [int64]
+    :
+    NEGATIVE FunctionCall test.int64@1[
+  LiteralExpr [STRING] [-640]
+]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.3.ast
new file mode 100644
index 0000000..70c074c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nullField]
+    :
+    NEGATIVE IndexAccessor [
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+  ]
+  Index:   OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+  ]
+]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.1.ast
new file mode 100644
index 0000000..073a7f8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.1.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+TypeDecl BatterType [
+  open RecordType {
+    id : int64,
+    descrpt : string
+  }
+]
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    description : string,
+    name : string,
+    batters : OrderedList [OrderedList [BatterType]
+]
+
+  }
+]
+DatasetDecl T1(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.3.ast
new file mode 100644
index 0000000..002d421
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list-ordered01/heterog-list-ordered01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [T1]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.1.ast
new file mode 100644
index 0000000..1969144
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl BatterType [
+  open RecordType {
+    id : int64,
+    descrpt : string
+  }
+]
+TypeDecl TestType [
+  closed RecordType {
+    id : int64,
+    description : string,
+    name : string,
+    batters : UnorderedList <BatterType>
+
+  }
+]
+DatasetDecl T1(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.3.ast
new file mode 100644
index 0000000..002d421
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/heterog-list01/heterog-list01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [T1]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.1.ast
new file mode 100644
index 0000000..ecd9935
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int64,
+    name : string
+  }
+]
+DatasetDecl testds(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.3.ast
new file mode 100644
index 0000000..25fd257
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-01/open-closed-01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.1.ast
new file mode 100644
index 0000000..e1a0b3c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.1.ast
@@ -0,0 +1,15 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+TypeDecl testtype02 [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.3.ast
new file mode 100644
index 0000000..07560d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-12/open-closed-12.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.1.ast
new file mode 100644
index 0000000..6ce44ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.1.ast
@@ -0,0 +1,14 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  closed RecordType {
+    id : string,
+    name : string?
+  }
+]
+TypeDecl testtype02 [
+  closed RecordType {
+    id : string
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.3.ast
new file mode 100644
index 0000000..07560d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-14/open-closed-14.3.ast
@@ -0,0 +1,18 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.1.ast
new file mode 100644
index 0000000..12f0cd8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.1.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int64,
+    name : string,
+    opt_tag : UnorderedList <string>
+
+  }
+]
+DatasetDecl testds(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.3.ast
new file mode 100644
index 0000000..16bb849
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-24/open-closed-24.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.1.ast
new file mode 100644
index 0000000..294f646
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.1.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int64,
+    name : string,
+    opt_tag : UnorderedList <string>
+?
+  }
+]
+DatasetDecl testds(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.3.ast
new file mode 100644
index 0000000..16bb849
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-25/open-closed-25.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.1.ast
new file mode 100644
index 0000000..294f646
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.1.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int64,
+    name : string,
+    opt_tag : UnorderedList <string>
+?
+  }
+]
+DatasetDecl testds(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.3.ast
new file mode 100644
index 0000000..16bb849
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-26/open-closed-26.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.1.ast
new file mode 100644
index 0000000..e1a0b3c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.1.ast
@@ -0,0 +1,15 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+TypeDecl testtype02 [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.3.ast
new file mode 100644
index 0000000..a5a324d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-29/open-closed-29.3.ast
@@ -0,0 +1,35 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+Variable [ Name=d ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=h ]
+    In
+      FieldAccessor [
+        Variable [ Name=d ]
+        Field=hobbies
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=h ]
+        =
+        LiteralExpr [STRING] [hiking]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.1.ast
new file mode 100644
index 0000000..e4bceee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.1.ast
@@ -0,0 +1,14 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  open RecordType {
+    id : string
+  }
+]
+TypeDecl testtype02 [
+  open RecordType {
+    id : string,
+    name : string
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.3.ast
new file mode 100644
index 0000000..1435afe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-31/open-closed-31.3.ast
@@ -0,0 +1,38 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=d ]
+  Field=hobbies
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=h ]
+    In
+      FieldAccessor [
+        Variable [ Name=d ]
+        Field=hobbies
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=h ]
+        =
+        LiteralExpr [STRING] [hiking]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.1.ast
new file mode 100644
index 0000000..4ef434c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.1.ast
@@ -0,0 +1,19 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  open RecordType {
+    id : string
+  }
+]
+TypeDecl testtype02 [
+  closed RecordType {
+    id : string,
+    name : string,
+    sex : string,
+    dept : string,
+    salary : int32,
+    interests : UnorderedList <string>
+
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.3.ast
new file mode 100644
index 0000000..c6c43cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-32/open-closed-32.3.ast
@@ -0,0 +1,38 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=d ]
+  Field=interests
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=h ]
+    In
+      FieldAccessor [
+        Variable [ Name=d ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=h ]
+        =
+        LiteralExpr [STRING] [biking]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.1.ast
new file mode 100644
index 0000000..73a7661
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.1.ast
@@ -0,0 +1,19 @@
+DataverseUse testdv2
+TypeDecl testtype01 [
+  open RecordType {
+    id : string
+  }
+]
+TypeDecl testtype02 [
+  closed RecordType {
+    id : string,
+    name : string,
+    sex : string,
+    dept : string,
+    salary : int32,
+    interests : UnorderedList <string>
+?
+  }
+]
+DatasetDecl testds01(testtype01) partitioned by [[id]]
+DatasetDecl testds02(testtype02) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.2.ast
new file mode 100644
index 0000000..80af7bf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.2.ast
@@ -0,0 +1 @@
+DataverseUse testdv2
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.3.ast
new file mode 100644
index 0000000..c6c43cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/open-closed-33/open-closed-33.3.ast
@@ -0,0 +1,38 @@
+DataverseUse testdv2
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=d ]
+  Field=interests
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds01]
+  ]
+  AS
+  Variable [ Name=d ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=h ]
+    In
+      FieldAccessor [
+        Variable [ Name=d ]
+        Field=interests
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=h ]
+        =
+        LiteralExpr [STRING] [biking]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=d ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue134/query-issue134.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue166/query-issue166.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue196/query-issue196.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue208/query-issue208.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue236/query-issue236.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue258/query-issue258.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343-2/query-issue343-2.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue343/query-issue343.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350-2/query-issue350-2.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue350/query-issue350.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue377/query-issue377.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue410/query-issue410.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423-2/query-issue423-2.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue423/query-issue423.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue442/query-issue442.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453-2/query-issue453-2.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue453/query-issue453.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.1.ast
new file mode 100644
index 0000000..e7e0e70
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl TypeOpen [
+  open RecordType {
+    id : int64,
+    int_m : int64,
+    int_o : int64?,
+    string_m : string,
+    string_o : string?
+  }
+]
+DatasetDecl DataOpen(TypeOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.3.ast
new file mode 100644
index 0000000..8783570
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue456/query-issue456.3.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  Variable [ Name=m ]
+  FunctionCall test.count@1[
+    Variable [ Name=id ]
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DataOpen]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+LetVariable [ Name=id ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=id
+  ]
+Groupby
+  Variable [ Name=m ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=int_m
+  ]
+  With
+  Variable [ Name=id ]
+  Variable [ Name=x ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.3.ast
new file mode 100644
index 0000000..5f9a35b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue465/query-issue465.3.ast
@@ -0,0 +1,17 @@
+Query:
+OrderedListConstructor [
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [r1]
+      :
+      LiteralExpr [LONG] [1234]
+    )
+  ]
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [r2]
+      :
+      LiteralExpr [LONG] [456]
+    )
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue487/query-issue487.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55-1/query-issue55-1.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue55/query-issue55.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.1.ast
new file mode 100644
index 0000000..841b417
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.1.ast
@@ -0,0 +1,14 @@
+DataverseUse fooverse
+TypeDecl bartype [
+  open RecordType {
+    baz : int64
+  }
+]
+TypeDecl footype [
+  open RecordType {
+    id : int64,
+    bars : OrderedList [bartype]
+?
+  }
+]
+DatasetDecl fooset(footype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.2.ast
new file mode 100644
index 0000000..5471224
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.2.ast
@@ -0,0 +1 @@
+DataverseUse fooverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.3.ast
new file mode 100644
index 0000000..60d7624
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue592/query-issue592.3.ast
@@ -0,0 +1,11 @@
+DataverseUse fooverse
+Query:
+SELECT ELEMENT [
+Variable [ Name=f ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [fooset]
+  ]
+  AS
+  Variable [ Name=f ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.1.ast
new file mode 100644
index 0000000..8ba2a61
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.1.ast
@@ -0,0 +1,9 @@
+DataverseUse fooverse
+TypeDecl FooType [
+  open RecordType {
+    id : int64,
+    numbers : OrderedList [int64]
+
+  }
+]
+DatasetDecl Foo(FooType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.2.ast
new file mode 100644
index 0000000..5471224
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.2.ast
@@ -0,0 +1 @@
+DataverseUse fooverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.3.ast
new file mode 100644
index 0000000..fba4dc7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-issue625/query-issue625.3.ast
@@ -0,0 +1,11 @@
+DataverseUse fooverse
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Foo]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.1.ast
new file mode 100644
index 0000000..cfe61f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : string,
+    user :       open RecordType {
+        screen-name : string,
+        lang : string,
+        friends_count : int64,
+        statuses_count : int64,
+        name : string,
+        followers_count : int64
+      }
+,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.3.ast
new file mode 100644
index 0000000..13c7cf3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal/query-proposal.3.ast
@@ -0,0 +1,75 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [topic]
+    :
+    Variable [ Name=tp2 ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      Variable [ Name=tp1 ]
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [topic]
+        :
+        Variable [ Name=tp ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [TweetMessages]
+      ]
+      AS
+      Variable [ Name=tweet ]
+,
+      FieldAccessor [
+        Variable [ Name=tweet ]
+        Field=referred-topics
+      ]
+      AS
+      Variable [ Name=tp ]
+    ]
+    Where
+      QuantifiedExpression SOME [
+        [Variable [ Name=topic ]
+        In
+          FieldAccessor [
+            Variable [ Name=tweet ]
+            Field=referred-topics
+          ]
+        ]
+        Satifies [
+          FunctionCall test.contains@2[
+            Variable [ Name=topic ]
+            LiteralExpr [STRING] [verizon]
+          ]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=tp1 ]
+]
+Groupby
+  Variable [ Name=tp2 ]
+  :=
+  FieldAccessor [
+    Variable [ Name=tp1 ]
+    Field=topic
+  ]
+  With
+  Variable [ Name=tp1 ]
+
+Orderby
+  Variable [ Name=tp2 ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.1.ast
new file mode 100644
index 0000000..cfe61f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : string,
+    user :       open RecordType {
+        screen-name : string,
+        lang : string,
+        friends_count : int64,
+        statuses_count : int64,
+        name : string,
+        followers_count : int64
+      }
+,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.3.ast
new file mode 100644
index 0000000..d58a2f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-closed/query-proposal02/query-proposal02.3.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [topic]
+    :
+    Variable [ Name=topic ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      Variable [ Name=tweet ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=tweet ]
+,
+  FieldAccessor [
+    Variable [ Name=tweet ]
+    Field=referred-topics
+  ]
+  AS
+  Variable [ Name=reftopic ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=reftopic ]
+    In
+      FieldAccessor [
+        Variable [ Name=tweet ]
+        Field=referred-topics
+      ]
+    ]
+    Satifies [
+      FunctionCall test.contains@2[
+        Variable [ Name=reftopic ]
+        LiteralExpr [STRING] [verizon]
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=topic ]
+  :=
+  Variable [ Name=reftopic ]
+  With
+  Variable [ Name=tweet ]
+  Variable [ Name=reftopic ]
+
+Orderby
+  Variable [ Name=topic ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/enforced-field-name-collision/enforced-field-name-collision.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/enforced-field-name-collision/enforced-field-name-collision.1.ast
new file mode 100644
index 0000000..707c24e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/enforced-field-name-collision/enforced-field-name-collision.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int32,
+    value : string
+  }
+]
+DatasetDecl testDS(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/enforced-field-type-collision/enforced-field-name-collision.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/enforced-field-type-collision/enforced-field-name-collision.1.ast
new file mode 100644
index 0000000..707c24e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/enforced-field-type-collision/enforced-field-name-collision.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int32,
+    value : string
+  }
+]
+DatasetDecl testDS(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/index-on-closed-type/index-on-closed-type.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/index-on-closed-type/index-on-closed-type.1.ast
new file mode 100644
index 0000000..ab144049
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/index-on-closed-type/index-on-closed-type.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl testType [
+  closed RecordType {
+    id : int32
+  }
+]
+DatasetDecl testDS(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ast
new file mode 100644
index 0000000..ec4fb20
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/error-checking/missing-enforce-statement/missing-enforce-statement.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl testType [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl testDS(testType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
new file mode 100644
index 0000000..2711138
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
new file mode 100644
index 0000000..317564b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ast
new file mode 100644
index 0000000..4969848
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.ast
new file mode 100644
index 0000000..d3b6da5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ast
new file mode 100644
index 0000000..1285374
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.ast
new file mode 100644
index 0000000..fe2fa6b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast
new file mode 100644
index 0000000..2aa4f79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast
new file mode 100644
index 0000000..9a0aef7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/btree-secondary-equi-join/btree-secondary-equi-join.4.ast
@@ -0,0 +1,66 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=authors
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=authors
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
new file mode 100644
index 0000000..a211a04
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.1.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerOpenType [
+  open RecordType {
+    cid : int64,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerOpenType) partitioned by [[cid]]
+DatasetDecl Customerstmp(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
new file mode 100644
index 0000000..6ad6d9e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [ed]
+    :
+    Variable [ Name=ed ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance@2[
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=name
+    ]
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=name
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=ed ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=ed ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.1.ast
new file mode 100644
index 0000000..d5ff6f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.1.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerOpenType [
+  open RecordType {
+    cid : int64,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : OrderedList [string]
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerOpenType) partitioned by [[cid]]
+DatasetDecl Customerstmp(CustomerType) partitioned by [[cid]]
+DatasetDecl Customers2(CustomerType) partitioned by [[cid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.4.ast
new file mode 100644
index 0000000..e9fb1bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-edit-distance/ngram-edit-distance.4.ast
@@ -0,0 +1,69 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.edit-distance@2[
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=name
+        ]
+        FieldAccessor [
+          Variable [ Name=b ]
+          Field=name
+        ]
+      ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=cid
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=cid
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=cid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
new file mode 100644
index 0000000..3fbbbc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
new file mode 100644
index 0000000..9e63784
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.ast
@@ -0,0 +1,88 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.1.ast
new file mode 100644
index 0000000..3fbbbc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.4.ast
new file mode 100644
index 0000000..20d5f94
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/ngram-jaccard/ngram-jaccard.4.ast
@@ -0,0 +1,78 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+        FunctionCall test.gram-tokens@3[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+          LiteralExpr [LONG] [3]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
new file mode 100644
index 0000000..4cc1478
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData1tmp(MyRecord) partitioned by [[id]]
+DatasetDecl MyData1(MyRecordOpen) partitioned by [[id]]
+DatasetDecl MyData2(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
new file mode 100644
index 0000000..ccd4ff4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.ast
@@ -0,0 +1,87 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [aid]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bid]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [apt]
+    :
+    FieldAccessor [
+      Variable [ Name=a ]
+      Field=point
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bp]
+    :
+    FieldAccessor [
+      Variable [ Name=b ]
+      Field=point
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData1]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData2]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=point
+      ]
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=point
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      !=
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.1.ast
new file mode 100644
index 0000000..3fbbbc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.4.ast
new file mode 100644
index 0000000..4d1c988
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard-inline/word-jaccard-inline.4.ast
@@ -0,0 +1,83 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+  (
+    LiteralExpr [STRING] [jacc]
+    :
+    Variable [ Name=jacc ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard@2[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=title
+      ]
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      Variable [ Name=jacc ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  Variable [ Name=jacc ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.1.ast
new file mode 100644
index 0000000..3fbbbc6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.1.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl CSXType [
+  closed RecordType {
+    id : int64,
+    csxid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
+DatasetDecl CSX(CSXType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.4.ast
new file mode 100644
index 0000000..0ec37cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-join/word-jaccard/word-jaccard.4.ast
@@ -0,0 +1,73 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [arec]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [brec]
+    :
+    Variable [ Name=b ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=a ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CSX]
+  ]
+  AS
+  Variable [ Name=b ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FunctionCall test.similarity-jaccard@2[
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=a ]
+            Field=title
+          ]
+        ]
+        FunctionCall test.word-tokens@1[
+          FieldAccessor [
+            Variable [ Name=b ]
+            Field=title
+          ]
+        ]
+      ]
+      >=
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=b ]
+        Field=id
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=b ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
new file mode 100644
index 0000000..30e5bad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
new file mode 100644
index 0000000..d3b6da5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=countA
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
new file mode 100644
index 0000000..30e5bad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
new file mode 100644
index 0000000..54e08f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.ast
@@ -0,0 +1,111 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=countA
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t2info]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [count2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=countB
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=countA
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=countB
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
new file mode 100644
index 0000000..85a7dc8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    sender-location : point,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
new file mode 100644
index 0000000..ddc1e3d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.ast
@@ -0,0 +1,123 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [id]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=tweetid
+        ]
+      )
+      (
+        LiteralExpr [STRING] [topics]
+        :
+        FieldAccessor [
+          Variable [ Name=t1 ]
+          Field=message-text
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [id]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [topics]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      LetVariable [ Name=sim ]
+        :=
+        FunctionCall test.edit-distance-check@3[
+          FieldAccessor [
+            Variable [ Name=t1 ]
+            Field=message-text
+          ]
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+          LiteralExpr [LONG] [7]
+        ]
+      Where
+        OperatorExpr [
+          IndexAccessor [
+            Variable [ Name=sim ]
+            Index:             Variable [ Name=sim ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesTmp]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    >
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [240]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
new file mode 100644
index 0000000..e7a264d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
new file mode 100644
index 0000000..317564b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.ast
@@ -0,0 +1,102 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        FunctionCall test.spatial-intersect@2[
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+          Variable [ Name=n ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
new file mode 100644
index 0000000..e7a264d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl TwitterUserType [
+  closed RecordType {
+    screen-name : string,
+    lang : string,
+    friends-count : int64,
+    statuses-count : int64,
+    name : string,
+    followers-count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  open RecordType {
+    tweetid : int64,
+    user : TwitterUserType,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string,
+    countA : int64,
+    countB : int64
+  }
+]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl TweetMessagesTmp(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
new file mode 100644
index 0000000..13d31f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.ast
@@ -0,0 +1,116 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweetid1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [loc1]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-message]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [tweetid2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=tweetid
+          ]
+        )
+        (
+          LiteralExpr [STRING] [loc2]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sender-location
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall test.spatial-intersect@2[
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=sender-location
+            ]
+            Variable [ Name=n ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+LetVariable [ Name=n ]
+  :=
+  FunctionCall test.create-circle@2[
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=sender-location
+    ]
+    LiteralExpr [DOUBLE] [0.5]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=tweetid
+    ]
+    <
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [10]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
new file mode 100644
index 0000000..789df2d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl EmpOpen [
+  open RecordType {
+    id : int64,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
+DatasetDecl employeeOpen(EmpOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast
new file mode 100644
index 0000000..4374c0a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.ast
@@ -0,0 +1,97 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fname]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=fname
+    ]
+  )
+  (
+    LiteralExpr [STRING] [lname]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=lname
+    ]
+  )
+  (
+    LiteralExpr [STRING] [age]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=dept
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employeeOpen]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      >
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      >
+      LiteralExpr [STRING] [Mattocks]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      <=
+      LiteralExpr [STRING] [Micco]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      <
+      LiteralExpr [STRING] [Vangieson]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
new file mode 100644
index 0000000..789df2d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.1.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+TypeDecl EmpOpen [
+  open RecordType {
+    id : int64,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
+DatasetDecl employeeOpen(EmpOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
new file mode 100644
index 0000000..4538044
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-composite-key/btree-index-composite-key.4.ast
@@ -0,0 +1,72 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [fname]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=fname
+    ]
+  )
+  (
+    LiteralExpr [STRING] [lname]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=lname
+    ]
+  )
+  (
+    LiteralExpr [STRING] [age]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=dept
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [employeeOpen]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=fname
+      ]
+      =
+      LiteralExpr [STRING] [Julio]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=lname
+      ]
+      =
+      LiteralExpr [STRING] [Isa]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
new file mode 100644
index 0000000..53ed1b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ast
@@ -0,0 +1,28 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderOpenType [
+  open RecordType {
+    o_orderkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl OrdersOpen(OrderOpenType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
new file mode 100644
index 0000000..8a15b80
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.ast
@@ -0,0 +1,110 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderstatus
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=o_custkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderstatus2]
+    :
+    FieldAccessor [
+      Variable [ Name=o2 ]
+      Field=o_orderstatus
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [OrdersOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [OrdersOpen]
+  ]
+  AS
+  Variable [ Name=o2 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [20]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderstatus
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=o2 ]
+        Field=o_orderstatus
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=o2 ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
new file mode 100644
index 0000000..ec2521b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-contains/inverted-index-ngram-contains.4.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dblpid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=dblpid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [misc]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=misc
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
new file mode 100644
index 0000000..95bc310
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLPtmp(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
new file mode 100644
index 0000000..8ce7812
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-contains/inverted-index-ngram-edit-distance-contains.4.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-contains@3[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
new file mode 100644
index 0000000..b6708c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
new file mode 100644
index 0000000..b819eaf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-panic/inverted-index-ngram-edit-distance-panic.4.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dblpid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=dblpid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [misc]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=misc
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast
new file mode 100644
index 0000000..95bc310
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLPtmp(DBLPType) partitioned by [[id]]
+DatasetDecl DBLP(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast
new file mode 100644
index 0000000..8a83757
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance-word-tokens/inverted-index-ngram-edit-distance-word-tokens.4.ast
@@ -0,0 +1,57 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+,
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+  AS
+  Variable [ Name=word ]
+]
+Where
+  IndexAccessor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+    Index:     FunctionCall test.edit-distance-check@3[
+      Variable [ Name=word ]
+      LiteralExpr [STRING] [Multmedia]
+      LiteralExpr [LONG] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
new file mode 100644
index 0000000..b6708c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
new file mode 100644
index 0000000..351a250
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-edit-distance/inverted-index-ngram-edit-distance.4.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dblpid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=dblpid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [misc]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=misc
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=ed ]
+  :=
+  FunctionCall test.edit-distance-check@3[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+    LiteralExpr [STRING] [Amihay Motro]
+    LiteralExpr [LONG] [1]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=ed ]
+    Index:     Variable [ Name=ed ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
new file mode 100644
index 0000000..a49a9d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-ngram-jaccard/inverted-index-ngram-jaccard.4.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dblpid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=dblpid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [misc]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=misc
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.gram-tokens@3[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.gram-tokens@3[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
new file mode 100644
index 0000000..ec2521b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-contains/inverted-index-word-contains.4.ast
@@ -0,0 +1,67 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dblpid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=dblpid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [misc]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=misc
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.contains@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+    LiteralExpr [STRING] [Multimedia]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
new file mode 100644
index 0000000..5ffda7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.1.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+TypeDecl DBLPOpenType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
+DatasetDecl DBLPOpen(DBLPOpenType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
new file mode 100644
index 0000000..300a290
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/inverted-index-word-jaccard/inverted-index-word-jaccard.4.ast
@@ -0,0 +1,71 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dblpid]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=dblpid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [title]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=title
+    ]
+  )
+  (
+    LiteralExpr [STRING] [authors]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=authors
+    ]
+  )
+  (
+    LiteralExpr [STRING] [misc]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=misc
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=title
+      ]
+    ]
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
new file mode 100644
index 0000000..53ed1b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.1.ast
@@ -0,0 +1,28 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderOpenType [
+  open RecordType {
+    o_orderkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl OrdersOpen(OrderOpenType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
new file mode 100644
index 0000000..3afcf57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey-conjunctive/orders-index-custkey-conjunctive.4.ast
@@ -0,0 +1,55 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [OrdersOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+      =
+      LiteralExpr [LONG] [40]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_totalprice
+      ]
+      >
+      LiteralExpr [DOUBLE] [150000.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.1.ast
new file mode 100644
index 0000000..53ed1b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.1.ast
@@ -0,0 +1,28 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl OrderOpenType [
+  open RecordType {
+    o_orderkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl OrdersOpen(OrderOpenType) partitioned by [[o_orderkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.3.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.3.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.4.ast
new file mode 100644
index 0000000..0b2750d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/orders-index-custkey/orders-index-custkey.4.ast
@@ -0,0 +1,44 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_orderkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [o_custkey]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [OrdersOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=o_custkey
+    ]
+    =
+    LiteralExpr [LONG] [40]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.1.ast
new file mode 100644
index 0000000..57e147f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.1.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl LineItemOpenType [
+  open RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl LineItemOpen(LineItemOpenType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.4.ast
new file mode 100644
index 0000000..d84a04d9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/range-search/range-search.4.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItemOpen]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      <
+      LiteralExpr [LONG] [100]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=l_suppkey
+      ]
+      >
+      LiteralExpr [LONG] [5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
new file mode 100644
index 0000000..cb10b17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.1.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyRecordOpen [
+  open RecordType {
+    id : int64,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyDataOpen(MyRecordOpen) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
new file mode 100644
index 0000000..7ab550f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/open-index-enforced/index-selection/rtree-secondary-index/rtree-secondary-index.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyDataOpen]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast
new file mode 100644
index 0000000..d836e4d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_01/everysat_01.3.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    NEGATIVE LiteralExpr [LONG] [30]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  QuantifiedExpression EVERY [
+    [Variable [ Name=y ]
+    In
+      OrderedListConstructor [
+        NEGATIVE LiteralExpr [LONG] [20]
+        NEGATIVE LiteralExpr [LONG] [10]
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=y ]
+        >
+        Variable [ Name=x ]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.3.ast
new file mode 100644
index 0000000..44d3f63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/everysat_04/everysat_04.3.ast
@@ -0,0 +1,118 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=x ]
+  :=
+  OrderedListConstructor [
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+    QuantifiedExpression EVERY [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=x ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast
new file mode 100644
index 0000000..a39bcb5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_01/somesat_01.3.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    NEGATIVE LiteralExpr [LONG] [30]
+    NEGATIVE LiteralExpr [LONG] [21]
+    LiteralExpr [LONG] [50]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=y ]
+    In
+      OrderedListConstructor [
+        NEGATIVE LiteralExpr [LONG] [20]
+        NEGATIVE LiteralExpr [LONG] [40]
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        Variable [ Name=y ]
+        >
+        Variable [ Name=x ]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.1.ast
new file mode 100644
index 0000000..c4acbb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.1.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    lastorder :       open RecordType {
+        oid : int64,
+        total : float
+      }
+
+  }
+]
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl CustomerSomeSat02(CustomerType) partitioned by [[cid]]
+DatasetDecl OrdersSomeSat02(OrderType) partitioned by [[oid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.3.ast
new file mode 100644
index 0000000..ab31857
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_02/somesat_02.3.ast
@@ -0,0 +1,43 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=x ]
+  Field=cid
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [CustomerSomeSat02]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=y ]
+    In
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [OrdersSomeSat02]
+      ]
+    ]
+    Satifies [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=y ]
+          Field=cid
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=x ]
+          Field=cid
+        ]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.3.ast
new file mode 100644
index 0000000..2ed5885
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/quantifiers/somesat_06/somesat_06.3.ast
@@ -0,0 +1,118 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=x ]
+  :=
+  OrderedListConstructor [
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        Variable [ Name=x ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [FALSE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [FALSE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+    QuantifiedExpression SOME [
+      [Variable [ Name=x ]
+      In
+        OrderedListConstructor [
+          LiteralExpr [TRUE]
+          LiteralExpr [TRUE]
+        ]
+      ]
+      Satifies [
+        FunctionCall test.not@1[
+          Variable [ Name=x ]
+        ]
+      ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=x ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.1.ast
new file mode 100644
index 0000000..3c0977d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.1.ast
@@ -0,0 +1,11 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen_name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.2.ast
new file mode 100644
index 0000000..98d00ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.2.ast
@@ -0,0 +1,2 @@
+DataverseUse TinySocial
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen_name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.4.ast
new file mode 100644
index 0000000..a1961c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_01/order-by-exception_01.4.ast
@@ -0,0 +1,17 @@
+DataverseUse TinySocial
+Query:
+  SELECT ELEMENT [
+  Variable [ Name=user Id=0 ]
+  ]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers] 
+  ]
+  Variable [ Name=user Id=0 ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user Id=0 ]
+    Field=screen_name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.1.ast
new file mode 100644
index 0000000..3c0977d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.1.ast
@@ -0,0 +1,11 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen_name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.2.ast
new file mode 100644
index 0000000..98d00ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.2.ast
@@ -0,0 +1,2 @@
+DataverseUse TinySocial
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen_name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.4.ast
new file mode 100644
index 0000000..fb2f736
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by-exception_02/order-by-exception_02.4.ast
@@ -0,0 +1,17 @@
+DataverseUse TinySocial
+Query:
+  SELECT ELEMENT [
+  Variable [ Name=user Id=0 ]
+  ]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers] 
+  ]
+  Variable [ Name=user Id=0 ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user Id=0 ]
+    Field=screen_name
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.1.ast
new file mode 100644
index 0000000..e95109f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.1.ast
@@ -0,0 +1,11 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.2.ast
new file mode 100644
index 0000000..2e695ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.2.ast
@@ -0,0 +1,2 @@
+DataverseUse TinySocial
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.4.ast
new file mode 100644
index 0000000..bfdfa6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.4.ast
@@ -0,0 +1,18 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=screen-name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.5.ast
new file mode 100644
index 0000000..bea7ba6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.5.ast
@@ -0,0 +1,18 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=screen-name
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.6.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.6.ast
new file mode 100644
index 0000000..f355a3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.6.ast
@@ -0,0 +1,18 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=friends_count
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.7.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.7.ast
new file mode 100644
index 0000000..0a275c4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/range-hints/order-by/order-by.7.ast
@@ -0,0 +1,18 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=friends_count
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.1.ast
new file mode 100644
index 0000000..15f6b7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.1.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+TypeDecl S [
+  open RecordType {
+    id : int64
+  }
+]
+TypeDecl GS [
+  closed RecordType {
+    id : int64,
+    Genus : string,
+    lower : S
+  }
+]
+TypeDecl FGS [
+  open RecordType {
+    id : int64,
+    Family : string
+  }
+]
+TypeDecl OFGS [
+  closed RecordType {
+    id : int64,
+    Order : string,
+    lower : FGS
+  }
+]
+TypeDecl COFGS [
+  closed RecordType {
+    id : int64,
+    Class : string,
+    lower : OFGS
+  }
+]
+TypeDecl PCOFGS [
+  closed RecordType {
+    id : int64,
+    Phylum : string,
+    lower : COFGS
+  }
+]
+TypeDecl KPCOFGS [
+  open RecordType {
+    id : int64,
+    Kingdom : string
+  }
+]
+TypeDecl Classification [
+  closed RecordType {
+    id : int64,
+    fullClassification : KPCOFGS
+  }
+]
+TypeDecl Animal [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl Animals(Animal) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.10.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.10.ast
new file mode 100644
index 0000000..f0ad634
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.10.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=test ]
+      Field=class
+    ]
+    Field=fullClassification
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.11.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.11.ast
new file mode 100644
index 0000000..a6821b5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.11.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    Variable [ Name=test ]
+    Field=class
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.12.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.12.ast
new file mode 100644
index 0000000..803de17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.12.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  Variable [ Name=test ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.3.ast
new file mode 100644
index 0000000..8e283f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.3.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        FieldAccessor [
+          FieldAccessor [
+            FieldAccessor [
+              FieldAccessor [
+                FieldAccessor [
+                  FieldAccessor [
+                    Variable [ Name=test ]
+                    Field=class
+                  ]
+                  Field=fullClassification
+                ]
+                Field=lower
+              ]
+              Field=lower
+            ]
+            Field=lower
+          ]
+          Field=lower
+        ]
+        Field=lower
+      ]
+      Field=lower
+    ]
+    Field=Species
+  ]
+Orderby
+  Variable [ Name=result ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.4.ast
new file mode 100644
index 0000000..37657b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.4.ast
@@ -0,0 +1,45 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        FieldAccessor [
+          FieldAccessor [
+            FieldAccessor [
+              FieldAccessor [
+                FieldAccessor [
+                  Variable [ Name=test ]
+                  Field=class
+                ]
+                Field=fullClassification
+              ]
+              Field=lower
+            ]
+            Field=lower
+          ]
+          Field=lower
+        ]
+        Field=lower
+      ]
+      Field=lower
+    ]
+    Field=lower
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.5.ast
new file mode 100644
index 0000000..d7bf2cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.5.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        FieldAccessor [
+          FieldAccessor [
+            FieldAccessor [
+              FieldAccessor [
+                Variable [ Name=test ]
+                Field=class
+              ]
+              Field=fullClassification
+            ]
+            Field=lower
+          ]
+          Field=lower
+        ]
+        Field=lower
+      ]
+      Field=lower
+    ]
+    Field=lower
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.6.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.6.ast
new file mode 100644
index 0000000..f1eba54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.6.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        FieldAccessor [
+          FieldAccessor [
+            FieldAccessor [
+              Variable [ Name=test ]
+              Field=class
+            ]
+            Field=fullClassification
+          ]
+          Field=lower
+        ]
+        Field=lower
+      ]
+      Field=lower
+    ]
+    Field=lower
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.7.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.7.ast
new file mode 100644
index 0000000..dc420c6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.7.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        FieldAccessor [
+          FieldAccessor [
+            Variable [ Name=test ]
+            Field=class
+          ]
+          Field=fullClassification
+        ]
+        Field=lower
+      ]
+      Field=lower
+    ]
+    Field=lower
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.8.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.8.ast
new file mode 100644
index 0000000..b3dd91b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.8.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        FieldAccessor [
+          Variable [ Name=test ]
+          Field=class
+        ]
+        Field=fullClassification
+      ]
+      Field=lower
+    ]
+    Field=lower
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.9.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.9.ast
new file mode 100644
index 0000000..eebd261
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/access-nested-fields/access-nested-fields.9.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      FieldAccessor [
+        Variable [ Name=test ]
+        Field=class
+      ]
+      Field=fullClassification
+    ]
+    Field=lower
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.3.ast
new file mode 100644
index 0000000..a34f71f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-closed-fieldname-conflict_issue173/closed-closed-fieldname-conflict_issue173.3.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [name]
+    :
+    LiteralExpr [STRING] [john]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    LiteralExpr [STRING] [smith]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.3.ast
new file mode 100644
index 0000000..e9e175b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_01/closed-record-constructor_01.3.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall test.closed-record-constructor@8[
+  LiteralExpr [STRING] [foo1]
+  LiteralExpr [LONG] [10]
+  LiteralExpr [STRING] [bar1]
+  LiteralExpr [LONG] [20]
+  LiteralExpr [STRING] [foo2]
+  LiteralExpr [LONG] [30]
+  LiteralExpr [STRING] [bar2]
+  LiteralExpr [LONG] [40]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.3.ast
new file mode 100644
index 0000000..a230856
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_02/closed-record-constructor_02.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall test.closed-record-constructor@8[
+  LiteralExpr [STRING] [foo1]
+  LiteralExpr [LONG] [10]
+  LiteralExpr [STRING] [bar1]
+  FunctionCall test.closed-record-constructor@12[
+    LiteralExpr [STRING] [bar1.1]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [STRING] [bar1.2]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [STRING] [bar1.3]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [STRING] [bar1.4]
+    FunctionCall test.closed-record-constructor@8[
+      LiteralExpr [STRING] [bar1.4.1]
+      LiteralExpr [LONG] [10]
+      LiteralExpr [STRING] [bar1.4.2]
+      LiteralExpr [LONG] [20]
+      LiteralExpr [STRING] [bar1.4.3]
+      LiteralExpr [LONG] [30]
+      LiteralExpr [STRING] [bar1.4.4]
+      LiteralExpr [LONG] [40]
+    ]
+    LiteralExpr [STRING] [foo2]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [STRING] [bar2]
+    LiteralExpr [LONG] [40]
+  ]
+  LiteralExpr [STRING] [foo2]
+  LiteralExpr [LONG] [30]
+  LiteralExpr [STRING] [bar2]
+  LiteralExpr [LONG] [40]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.3.ast
new file mode 100644
index 0000000..387ad1a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/closed-record-constructor_03/closed-record-constructor_03.3.ast
@@ -0,0 +1,59 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [foo1]
+    :
+    LiteralExpr [LONG] [10]
+  )
+  (
+    LiteralExpr [STRING] [bar1]
+    :
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [bar1.1]
+        :
+        LiteralExpr [LONG] [10]
+      )
+      (
+        LiteralExpr [STRING] [bar1.2]
+        :
+        LiteralExpr [LONG] [20]
+      )
+      (
+        LiteralExpr [STRING] [bar1.3]
+        :
+        LiteralExpr [LONG] [30]
+      )
+      (
+        LiteralExpr [STRING] [bar1.4]
+        :
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [bar1.4.1]
+            :
+            LiteralExpr [LONG] [10]
+          )
+          (
+            LiteralExpr [STRING] [bar1.4.2]
+            :
+            LiteralExpr [LONG] [20]
+          )
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [foo2]
+    :
+    LiteralExpr [LONG] [30]
+  )
+  (
+    LiteralExpr [STRING] [bar2]
+    :
+    LiteralExpr [LONG] [40]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.3.ast
new file mode 100644
index 0000000..c13fcb9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/expFieldName/expFieldName.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    Variable [ Name=x ]
+    :
+    LiteralExpr [LONG] [1]
+  )
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [field1]
+    LiteralExpr [STRING] [field2]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.3.ast
new file mode 100644
index 0000000..9d46669
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-by-index_01/field-access-by-index_01.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+FunctionCall test.field-access-by-index@2[
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [foo1]
+      :
+      LiteralExpr [LONG] [10]
+    )
+    (
+      LiteralExpr [STRING] [bar1]
+      :
+      LiteralExpr [LONG] [20]
+    )
+    (
+      LiteralExpr [STRING] [foo2]
+      :
+      LiteralExpr [LONG] [30]
+    )
+    (
+      LiteralExpr [STRING] [bar2]
+      :
+      LiteralExpr [LONG] [40]
+    )
+  ]
+  FunctionCall test.int32@1[
+    LiteralExpr [STRING] [2]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.1.ast
new file mode 100644
index 0000000..8be0f50
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    name : string
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.3.ast
new file mode 100644
index 0000000..f429567
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/field-access-on-open-field/field-access-on-open-field.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=a ]
+  Field=zip
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+LetVariable [ Name=a ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=address
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.1.ast
new file mode 100644
index 0000000..ccbee67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.1.ast
@@ -0,0 +1,41 @@
+Query:
+FunctionCall null.get-record-field-value@2[
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [id]
+      :
+      LiteralExpr [LONG] [1]
+    )
+    (
+      LiteralExpr [STRING] [project]
+      :
+      LiteralExpr [STRING] [AsterixDB]
+    )
+    (
+      LiteralExpr [STRING] [address]
+      :
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [city]
+          :
+          LiteralExpr [STRING] [Irvine]
+        )
+        (
+          LiteralExpr [STRING] [state]
+          :
+          LiteralExpr [STRING] [CA]
+        )
+      ]
+    )
+    (
+      LiteralExpr [STRING] [related]
+      :
+      OrderedListConstructor [
+        LiteralExpr [STRING] [Hivestrix]
+        LiteralExpr [STRING] [Preglix]
+        LiteralExpr [STRING] [Apache VXQuery]
+      ]
+    )
+  ]
+  LiteralExpr [STRING] [project]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.2.ast
new file mode 100644
index 0000000..d9f4315
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.2.ast
@@ -0,0 +1,41 @@
+Query:
+FunctionCall null.get-record-field-value@2[
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [id]
+      :
+      LiteralExpr [LONG] [1]
+    )
+    (
+      LiteralExpr [STRING] [project]
+      :
+      LiteralExpr [STRING] [AsterixDB]
+    )
+    (
+      LiteralExpr [STRING] [address]
+      :
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [city]
+          :
+          LiteralExpr [STRING] [Irvine]
+        )
+        (
+          LiteralExpr [STRING] [state]
+          :
+          LiteralExpr [STRING] [CA]
+        )
+      ]
+    )
+    (
+      LiteralExpr [STRING] [related]
+      :
+      OrderedListConstructor [
+        LiteralExpr [STRING] [Hivestrix]
+        LiteralExpr [STRING] [Preglix]
+        LiteralExpr [STRING] [Apache VXQuery]
+      ]
+    )
+  ]
+  LiteralExpr [STRING] [address]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.3.ast
new file mode 100644
index 0000000..701736f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/documentation-example/documentation-example.3.ast
@@ -0,0 +1,41 @@
+Query:
+FunctionCall null.get-record-field-value@2[
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [id]
+      :
+      LiteralExpr [LONG] [1]
+    )
+    (
+      LiteralExpr [STRING] [project]
+      :
+      LiteralExpr [STRING] [AsterixDB]
+    )
+    (
+      LiteralExpr [STRING] [address]
+      :
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [city]
+          :
+          LiteralExpr [STRING] [Irvine]
+        )
+        (
+          LiteralExpr [STRING] [state]
+          :
+          LiteralExpr [STRING] [CA]
+        )
+      ]
+    )
+    (
+      LiteralExpr [STRING] [related]
+      :
+      OrderedListConstructor [
+        LiteralExpr [STRING] [Hivestrix]
+        LiteralExpr [STRING] [Preglix]
+        LiteralExpr [STRING] [Apache VXQuery]
+      ]
+    )
+  ]
+  LiteralExpr [STRING] [related]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.1.ast
new file mode 100644
index 0000000..34dc4c3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.1.ast
@@ -0,0 +1,62 @@
+DataverseUse test
+TypeDecl S [
+  closed RecordType {
+    id : int64,
+    Species : string
+  }
+]
+TypeDecl GS [
+  closed RecordType {
+    id : int64,
+    Genus : string,
+    lower : S
+  }
+]
+TypeDecl FGS [
+  closed RecordType {
+    id : int64,
+    Family : string,
+    lower : GS
+  }
+]
+TypeDecl OFGS [
+  closed RecordType {
+    id : int64,
+    Order : string,
+    lower : FGS
+  }
+]
+TypeDecl COFGS [
+  closed RecordType {
+    id : int64,
+    Class : string,
+    lower : OFGS
+  }
+]
+TypeDecl PCOFGS [
+  closed RecordType {
+    id : int64,
+    Phylum : string,
+    lower : COFGS
+  }
+]
+TypeDecl KPCOFGS [
+  closed RecordType {
+    id : int64,
+    Kingdom : string,
+    lower : PCOFGS
+  }
+]
+TypeDecl Classification [
+  closed RecordType {
+    id : int64,
+    fullClassification : KPCOFGS
+  }
+]
+TypeDecl Animal [
+  closed RecordType {
+    id : int64,
+    class : Classification
+  }
+]
+DatasetDecl Animals(Animal) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.3.ast
new file mode 100644
index 0000000..6e63c7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-closed/highly-nested-open.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FunctionCall test.get-record-field-value@2[
+    Variable [ Name=test ]
+    LiteralExpr [STRING] [class]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.1.ast
new file mode 100644
index 0000000..8821a69
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.1.ast
@@ -0,0 +1,58 @@
+DataverseUse test
+TypeDecl S [
+  open RecordType {
+    id : int64
+  }
+]
+TypeDecl GS [
+  closed RecordType {
+    id : int64,
+    Genus : string,
+    lower : S
+  }
+]
+TypeDecl FGS [
+  open RecordType {
+    id : int64,
+    Family : string
+  }
+]
+TypeDecl OFGS [
+  closed RecordType {
+    id : int64,
+    Order : string,
+    lower : FGS
+  }
+]
+TypeDecl COFGS [
+  open RecordType {
+    id : int64,
+    Class : string,
+    lower : OFGS
+  }
+]
+TypeDecl PCOFGS [
+  closed RecordType {
+    id : int64,
+    Phylum : string,
+    lower : COFGS
+  }
+]
+TypeDecl KPCOFGS [
+  open RecordType {
+    id : int64,
+    Kingdom : string
+  }
+]
+TypeDecl Classification [
+  closed RecordType {
+    id : int64,
+    fullClassification : KPCOFGS
+  }
+]
+TypeDecl Animal [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl Animals(Animal) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.3.ast
new file mode 100644
index 0000000..6e63c7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-mixed/highly-nested-mixed.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FunctionCall test.get-record-field-value@2[
+    Variable [ Name=test ]
+    LiteralExpr [STRING] [class]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.1.ast
new file mode 100644
index 0000000..363845b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.1.ast
@@ -0,0 +1,53 @@
+DataverseUse test
+TypeDecl S [
+  open RecordType {
+    id : int64
+  }
+]
+TypeDecl GS [
+  open RecordType {
+    id : int64,
+    Genus : string
+  }
+]
+TypeDecl FGS [
+  open RecordType {
+    id : int64,
+    Family : string
+  }
+]
+TypeDecl OFGS [
+  open RecordType {
+    id : int64,
+    Order : string
+  }
+]
+TypeDecl COFGS [
+  open RecordType {
+    id : int64,
+    Class : string
+  }
+]
+TypeDecl PCOFGS [
+  open RecordType {
+    id : int64,
+    Phylum : string
+  }
+]
+TypeDecl KPCOFGS [
+  open RecordType {
+    id : int64,
+    Kingdom : string
+  }
+]
+TypeDecl Classification [
+  open RecordType {
+    id : int64
+  }
+]
+TypeDecl Animal [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl Animals(Animal) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.3.ast
new file mode 100644
index 0000000..6e63c7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/highly-nested-open/highly-nested-open.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Animals]
+  ]
+  AS
+  Variable [ Name=test ]
+]
+LetVariable [ Name=result ]
+  :=
+  FunctionCall test.get-record-field-value@2[
+    Variable [ Name=test ]
+    LiteralExpr [STRING] [class]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=result ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.1.ast
new file mode 100644
index 0000000..e0d0fd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.1.ast
@@ -0,0 +1,50 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.2.ast
new file mode 100644
index 0000000..a6e2ec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.2.ast
@@ -0,0 +1,5 @@
+DataverseUse TinySocial
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.4.ast
new file mode 100644
index 0000000..5d8ed8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-field-value/tiny-social-example/tiny-social-example.4.ast
@@ -0,0 +1,39 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=result ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=r ]
+,
+  FunctionCall TinySocial.get-record-fields@1[
+    Variable [ Name=r ]
+  ]
+  AS
+  Variable [ Name=f ]
+]
+LetVariable [ Name=result ]
+  :=
+  FunctionCall TinySocial.get-record-field-value@2[
+    Variable [ Name=r ]
+    FieldAccessor [
+      Variable [ Name=f ]
+      Field=field-name
+    ]
+  ]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=f ]
+      Field=field-type
+    ]
+    =
+    LiteralExpr [STRING] [STRING]
+  ]
+Orderby
+  Variable [ Name=result ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/documentation-example/documentation-example.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/documentation-example/documentation-example.1.ast
new file mode 100644
index 0000000..f9cdeed
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/documentation-example/documentation-example.1.ast
@@ -0,0 +1,40 @@
+Query:
+FunctionCall null.get-record-fields@1[
+  RecordConstructor [
+    (
+      LiteralExpr [STRING] [id]
+      :
+      LiteralExpr [LONG] [1]
+    )
+    (
+      LiteralExpr [STRING] [project]
+      :
+      LiteralExpr [STRING] [AsterixDB]
+    )
+    (
+      LiteralExpr [STRING] [address]
+      :
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [city]
+          :
+          LiteralExpr [STRING] [Irvine]
+        )
+        (
+          LiteralExpr [STRING] [state]
+          :
+          LiteralExpr [STRING] [CA]
+        )
+      ]
+    )
+    (
+      LiteralExpr [STRING] [related]
+      :
+      OrderedListConstructor [
+        LiteralExpr [STRING] [Hivestrix]
+        LiteralExpr [STRING] [Preglix]
+        LiteralExpr [STRING] [Apache VXQuery]
+      ]
+    )
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.1.ast
new file mode 100644
index 0000000..e9d0b6f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.1.ast
@@ -0,0 +1,88 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
+TypeDecl TwitterUserAlternateType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64
+  }
+]
+TypeDecl TweetMessageAlternateType [
+  closed RecordType {
+    tweetid : string,
+    sender-location : point?,
+    send-time : datetime,
+    message-text : string
+  }
+]
+TypeDecl EmploymentAlternateType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserAlternateType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime
+  }
+]
+TypeDecl FacebookMessageAlternateType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.2.ast
new file mode 100644
index 0000000..a2fb376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.2.ast
@@ -0,0 +1,9 @@
+DataverseUse TinySocial
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl FacebookUsersAlternate(FacebookUserAlternateType) partitioned by [[id]]
+DatasetDecl FacebookMessagesAlternate(FacebookMessageAlternateType) partitioned by [[message-id]]
+DatasetDecl TwitterUsersAlternate(TwitterUserAlternateType) partitioned by [[screen-name]]
+DatasetDecl TweetMessagesAlternate(TweetMessageAlternateType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.4.ast
new file mode 100644
index 0000000..bed8129
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.4.ast
@@ -0,0 +1,22 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=user ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsersAlternate]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+    =
+    LiteralExpr [LONG] [8]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.5.ast
new file mode 100644
index 0000000..1be4993
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.5.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsersAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.6.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.6.ast
new file mode 100644
index 0000000..5eb193e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.6.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=message-id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.7.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.7.ast
new file mode 100644
index 0000000..47fd6ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.7.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsersAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=screen-name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.8.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.8.ast
new file mode 100644
index 0000000..783d5d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.8.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.9.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.9.ast
new file mode 100644
index 0000000..3fe1794
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-no-complex-types/tiny-social-example-no-complex-types.9.ast
@@ -0,0 +1,61 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [field-name]
+    :
+    Variable [ Name=n ]
+  )
+  (
+    LiteralExpr [STRING] [field-type]
+    :
+    Variable [ Name=t ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    Variable [ Name=count ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+,
+  FunctionCall TinySocial.get-record-fields@1[
+    Variable [ Name=r ]
+  ]
+  AS
+  Variable [ Name=f ]
+]
+Groupby
+  Variable [ Name=n ]
+  :=
+  FieldAccessor [
+    Variable [ Name=f ]
+    Field=field-name
+  ]
+  Variable [ Name=t ]
+  :=
+  FieldAccessor [
+    Variable [ Name=f ]
+    Field=field-type
+  ]
+  With
+  Variable [ Name=r ]
+  Variable [ Name=f ]
+
+LetVariable [ Name=count ]
+  :=
+  FunctionCall TinySocial.count@1[
+    Variable [ Name=r ]
+  ]
+Orderby
+  Variable [ Name=n ]
+  ASC
+  Variable [ Name=t ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.1.ast
new file mode 100644
index 0000000..5f2a3ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.1.ast
@@ -0,0 +1,92 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
+TypeDecl TwitterUserAlternateType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64
+  }
+]
+TypeDecl TweetMessageAlternateType [
+  closed RecordType {
+    tweetid : string,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl EmploymentAlternateType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserAlternateType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    friend-ids : UnorderedList <int64>
+,
+    user-since : datetime
+  }
+]
+TypeDecl FacebookMessageAlternateType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.2.ast
new file mode 100644
index 0000000..a2fb376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.2.ast
@@ -0,0 +1,9 @@
+DataverseUse TinySocial
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl FacebookUsersAlternate(FacebookUserAlternateType) partitioned by [[id]]
+DatasetDecl FacebookMessagesAlternate(FacebookMessageAlternateType) partitioned by [[message-id]]
+DatasetDecl TwitterUsersAlternate(TwitterUserAlternateType) partitioned by [[screen-name]]
+DatasetDecl TweetMessagesAlternate(TweetMessageAlternateType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.4.ast
new file mode 100644
index 0000000..bed8129
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.4.ast
@@ -0,0 +1,22 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=user ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsersAlternate]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+    =
+    LiteralExpr [LONG] [8]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.5.ast
new file mode 100644
index 0000000..1be4993
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.5.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsersAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.6.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.6.ast
new file mode 100644
index 0000000..5eb193e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.6.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=message-id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.7.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.7.ast
new file mode 100644
index 0000000..47fd6ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.7.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsersAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=screen-name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.8.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.8.ast
new file mode 100644
index 0000000..783d5d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.8.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.9.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.9.ast
new file mode 100644
index 0000000..3fe1794
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-lists/tiny-social-example-only-lists.9.ast
@@ -0,0 +1,61 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [field-name]
+    :
+    Variable [ Name=n ]
+  )
+  (
+    LiteralExpr [STRING] [field-type]
+    :
+    Variable [ Name=t ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    Variable [ Name=count ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+,
+  FunctionCall TinySocial.get-record-fields@1[
+    Variable [ Name=r ]
+  ]
+  AS
+  Variable [ Name=f ]
+]
+Groupby
+  Variable [ Name=n ]
+  :=
+  FieldAccessor [
+    Variable [ Name=f ]
+    Field=field-name
+  ]
+  Variable [ Name=t ]
+  :=
+  FieldAccessor [
+    Variable [ Name=f ]
+    Field=field-type
+  ]
+  With
+  Variable [ Name=r ]
+  Variable [ Name=f ]
+
+LetVariable [ Name=count ]
+  :=
+  FunctionCall TinySocial.count@1[
+    Variable [ Name=r ]
+  ]
+Orderby
+  Variable [ Name=n ]
+  ASC
+  Variable [ Name=t ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.1.ast
new file mode 100644
index 0000000..bb3d700
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.1.ast
@@ -0,0 +1,90 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
+TypeDecl TwitterUserAlternateType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64
+  }
+]
+TypeDecl TweetMessageAlternateType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserAlternateType,
+    sender-location : point?,
+    send-time : datetime,
+    message-text : string
+  }
+]
+TypeDecl EmploymentAlternateType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserAlternateType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    employment : EmploymentAlternateType
+  }
+]
+TypeDecl FacebookMessageAlternateType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.2.ast
new file mode 100644
index 0000000..a2fb376
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.2.ast
@@ -0,0 +1,9 @@
+DataverseUse TinySocial
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
+DatasetDecl FacebookUsersAlternate(FacebookUserAlternateType) partitioned by [[id]]
+DatasetDecl FacebookMessagesAlternate(FacebookMessageAlternateType) partitioned by [[message-id]]
+DatasetDecl TwitterUsersAlternate(TwitterUserAlternateType) partitioned by [[screen-name]]
+DatasetDecl TweetMessagesAlternate(TweetMessageAlternateType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.4.ast
new file mode 100644
index 0000000..bed8129
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.4.ast
@@ -0,0 +1,22 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=user ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsersAlternate]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+    =
+    LiteralExpr [LONG] [8]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.5.ast
new file mode 100644
index 0000000..1be4993
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.5.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsersAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.6.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.6.ast
new file mode 100644
index 0000000..5eb193e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.6.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=message-id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.7.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.7.ast
new file mode 100644
index 0000000..47fd6ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.7.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterUsersAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=screen-name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.8.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.8.ast
new file mode 100644
index 0000000..783d5d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.8.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.get-record-fields@1[
+  Variable [ Name=r ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.9.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.9.ast
new file mode 100644
index 0000000..3fe1794
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/get-record-fields/tiny-social-example-only-records/tiny-social-example-only-records.9.ast
@@ -0,0 +1,61 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [field-name]
+    :
+    Variable [ Name=n ]
+  )
+  (
+    LiteralExpr [STRING] [field-type]
+    :
+    Variable [ Name=t ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    Variable [ Name=count ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessagesAlternate]
+  ]
+  AS
+  Variable [ Name=r ]
+,
+  FunctionCall TinySocial.get-record-fields@1[
+    Variable [ Name=r ]
+  ]
+  AS
+  Variable [ Name=f ]
+]
+Groupby
+  Variable [ Name=n ]
+  :=
+  FieldAccessor [
+    Variable [ Name=f ]
+    Field=field-name
+  ]
+  Variable [ Name=t ]
+  :=
+  FieldAccessor [
+    Variable [ Name=f ]
+    Field=field-type
+  ]
+  With
+  Variable [ Name=r ]
+  Variable [ Name=f ]
+
+LetVariable [ Name=count ]
+  :=
+  FunctionCall TinySocial.count@1[
+    Variable [ Name=r ]
+  ]
+Orderby
+  Variable [ Name=n ]
+  ASC
+  Variable [ Name=t ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.1.ast
new file mode 100644
index 0000000..f901da6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl opentype [
+  open RecordType {
+    id : int32,
+    fname : string
+  }
+]
+DatasetDecl testds(opentype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.3.ast
new file mode 100644
index 0000000..0fa6075
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-closed-fieldname-conflict_issue173/open-closed-fieldname-conflict_issue173.3.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=fname
+    ]
+    :
+    LiteralExpr [STRING] [smith]
+  )
+  (
+    FunctionCall test.lowercase@1[
+      LiteralExpr [STRING] [NAME]
+    ]
+    :
+    LiteralExpr [STRING] [john]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.1.ast
new file mode 100644
index 0000000..1d7b726
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl opentype [
+  open RecordType {
+    fname1 : string,
+    fname2 : string
+  }
+]
+DatasetDecl testds(opentype) partitioned by [[fname1]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.3.ast
new file mode 100644
index 0000000..6509c79
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-open-fieldname-conflict_issue173/open-open-fieldname-conflict_issue173.3.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=fname1
+    ]
+    :
+    LiteralExpr [STRING] [john]
+  )
+  (
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=fname2
+    ]
+    :
+    LiteralExpr [STRING] [smith]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.3.ast
new file mode 100644
index 0000000..ec19477
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_01/open-record-constructor_01.3.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall test.open-record-constructor@8[
+  LiteralExpr [STRING] [foo1]
+  LiteralExpr [LONG] [10]
+  LiteralExpr [STRING] [bar1]
+  LiteralExpr [LONG] [20]
+  LiteralExpr [STRING] [foo2]
+  LiteralExpr [LONG] [30]
+  LiteralExpr [STRING] [bar2]
+  LiteralExpr [LONG] [40]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.3.ast
new file mode 100644
index 0000000..db26503
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/records/open-record-constructor_02/open-record-constructor_02.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall test.open-record-constructor@8[
+  LiteralExpr [STRING] [foo1]
+  LiteralExpr [LONG] [10]
+  LiteralExpr [STRING] [bar1]
+  FunctionCall test.closed-record-constructor@12[
+    LiteralExpr [STRING] [bar1.1]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [STRING] [bar1.2]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [STRING] [bar1.3]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [STRING] [bar1.4]
+    FunctionCall test.closed-record-constructor@8[
+      LiteralExpr [STRING] [bar1.4.1]
+      LiteralExpr [LONG] [10]
+      LiteralExpr [STRING] [bar1.4.2]
+      LiteralExpr [LONG] [20]
+      LiteralExpr [STRING] [bar1.4.3]
+      LiteralExpr [LONG] [30]
+      LiteralExpr [STRING] [bar1.4.4]
+      LiteralExpr [LONG] [40]
+    ]
+    LiteralExpr [STRING] [foo2]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [STRING] [bar2]
+    LiteralExpr [LONG] [40]
+  ]
+  LiteralExpr [STRING] [foo2]
+  LiteralExpr [LONG] [30]
+  LiteralExpr [STRING] [bar2]
+  LiteralExpr [LONG] [40]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.1.ast
new file mode 100644
index 0000000..3a8906e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  open RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP1(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.3.ast
new file mode 100644
index 0000000..ddad342
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/10/10.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP1]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.1.ast
new file mode 100644
index 0000000..7d94e66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLPadm(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.3.ast
new file mode 100644
index 0000000..7f1360c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/20/20.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPadm]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=paper ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.1.ast
new file mode 100644
index 0000000..49efe0f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLPsplits(DBLPType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.3.ast
new file mode 100644
index 0000000..f71c9bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/30/30.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLPsplits]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.1.ast
new file mode 100644
index 0000000..6322327
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.1.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl AllType [
+  open RecordType {
+    id : int64,
+    string : string,
+    float : float,
+    double : double,
+    boolean : boolean,
+    int8 : int8,
+    int16 : int16,
+    int32 : int32,
+    int64 : int64,
+    unorderedList : UnorderedList <string>
+,
+    orderedList : OrderedList [string]
+,
+    record : AddressType,
+    date : date,
+    time : time,
+    datetime : datetime,
+    duration : duration,
+    point : point,
+    point3d : point3d,
+    line : line,
+    rectangle : rectangle,
+    polygon : polygon,
+    circle : circle,
+    binary : binary,
+    uuid : uuid
+  }
+]
+DatasetDecl All(AllType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.3.ast
new file mode 100644
index 0000000..d119287
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_01/alltypes_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [All]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.1.ast
new file mode 100644
index 0000000..6322327
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.1.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl AllType [
+  open RecordType {
+    id : int64,
+    string : string,
+    float : float,
+    double : double,
+    boolean : boolean,
+    int8 : int8,
+    int16 : int16,
+    int32 : int32,
+    int64 : int64,
+    unorderedList : UnorderedList <string>
+,
+    orderedList : OrderedList [string]
+,
+    record : AddressType,
+    date : date,
+    time : time,
+    datetime : datetime,
+    duration : duration,
+    point : point,
+    point3d : point3d,
+    line : line,
+    rectangle : rectangle,
+    polygon : polygon,
+    circle : circle,
+    binary : binary,
+    uuid : uuid
+  }
+]
+DatasetDecl All(AllType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.3.ast
new file mode 100644
index 0000000..d119287
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/alltypes_02/alltypes_02.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [All]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.1.ast
new file mode 100644
index 0000000..1c2263b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl Employee [
+  closed RecordType {
+    id : int32,
+    name : string,
+    salary : int32
+  }
+]
+DatasetDecl Office(Employee) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.3.ast
new file mode 100644
index 0000000..2a6caa5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/invalid-scan-syntax/invalid-scan-syntax.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=t ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test.Office]
+  ]
+  AS
+  Variable [ Name=t ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_1/issue238_query_1.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/issue238_query_2/issue238_query_2.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.1.ast
new file mode 100644
index 0000000..55906f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.1.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+TypeDecl NumericType [
+  open RecordType {
+    id : int64,
+    int8Field : int8?,
+    int16Field : int16?,
+    int32Field : int32?,
+    int64Field : int64?,
+    floatField : float?,
+    doubleField : double?
+  }
+]
+DatasetDecl Numeric(NumericType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.3.ast
new file mode 100644
index 0000000..78fb696
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/numeric_types_01/numeric_types_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Numeric]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.1.ast
new file mode 100644
index 0000000..2bb8615
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl SpatialType [
+  open RecordType {
+    id : int64,
+    point : point,
+    point3d : point3d,
+    line : line,
+    polygon : polygon,
+    circle : circle
+  }
+]
+DatasetDecl Spatial(SpatialType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.3.ast
new file mode 100644
index 0000000..a9aa43f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/spatial_types_01/spatial_types_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Spatial]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.1.ast
new file mode 100644
index 0000000..268fab0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl TempType [
+  open RecordType {
+    id : int64,
+    date : date,
+    time : time,
+    datetime : datetime,
+    duration : duration
+  }
+]
+DatasetDecl Temp(TempType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.3.ast
new file mode 100644
index 0000000..469457b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/scan/temp_types_01/temp_types_01.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Temp]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.1.ast
new file mode 100644
index 0000000..042b445
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.3.ast
new file mode 100644
index 0000000..bc36184
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/count-nullable/count-nullable.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [custage]
+    :
+    Variable [ Name=age ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      Variable [ Name=c ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Groupby
+  Variable [ Name=age ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=age
+  ]
+  With
+  Variable [ Name=c ]
+
+Orderby
+  Variable [ Name=age ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.1.ast
new file mode 100644
index 0000000..042b445
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.1.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+TypeDecl AddressType [
+  open RecordType {
+    number : int64,
+    street : string,
+    city : string
+  }
+]
+TypeDecl CustomerType [
+  open RecordType {
+    cid : int64,
+    name : string,
+    age : int64?,
+    address : AddressType?,
+    interests : UnorderedList <string>
+,
+    children : OrderedList [          open RecordType {
+            name : string,
+            age : int64?
+          }
+]
+
+  }
+]
+DatasetDecl Customers(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.3.ast
new file mode 100644
index 0000000..32003f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/cust-filter/cust-filter.3.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [custname]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [custage]
+    :
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customers]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=age
+    ]
+    <
+    LiteralExpr [LONG] [21]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=cid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.1.ast
new file mode 100644
index 0000000..b7d8f2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl OrderType [
+  open RecordType {
+    oid : int64,
+    cid : int64,
+    orderstatus : string,
+    orderpriority : string,
+    clerk : string,
+    total : float
+  }
+]
+DatasetDecl Orders(OrderType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast
new file mode 100644
index 0000000..b8827d6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=o ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.not@1[
+    FunctionCall test.is-null@1[
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=param1
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=oid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.3.ast
new file mode 100644
index 0000000..441a66b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_ints/edit-distance-check_ints.3.ast
@@ -0,0 +1,54 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [7]
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [3]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [3]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [2]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [2]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.3.ast
new file mode 100644
index 0000000..bc90e22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_strings/edit-distance-check_strings.3.ast
@@ -0,0 +1,39 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  LiteralExpr [STRING] [Nalini Venkatasubramanian]
+LetVariable [ Name=b ]
+  :=
+  LiteralExpr [STRING] [Nalini Wekatasupramanian]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [3]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [3]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [2]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [2]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.3.ast
new file mode 100644
index 0000000..227a6b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-check_unicode/edit-distance-check_unicode.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  LiteralExpr [STRING] [사랑]
+LetVariable [ Name=b ]
+  :=
+  LiteralExpr [STRING] [사랑해]
+LetVariable [ Name=c ]
+  :=
+  LiteralExpr [STRING] [사과]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [1]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [1]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=c ]
+      LiteralExpr [LONG] [1]
+    ]
+    FunctionCall test.edit-distance-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [2]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.ast
new file mode 100644
index 0000000..adabd87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-list-is-filterable/edit-distance-list-is-filterable.3.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [10]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance-list-is-filterable@2[
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [0]
+    ]
+    FunctionCall test.edit-distance-list-is-filterable@2[
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [3]
+    ]
+    FunctionCall test.edit-distance-list-is-filterable@2[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [0]
+    ]
+    FunctionCall test.edit-distance-list-is-filterable@2[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [3]
+    ]
+    FunctionCall test.edit-distance-list-is-filterable@2[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [8]
+    ]
+    FunctionCall test.edit-distance-list-is-filterable@2[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [11]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.ast
new file mode 100644
index 0000000..f3ca20c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance-string-is-filterable/edit-distance-string-is-filterable.3.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  LiteralExpr [STRING] []
+LetVariable [ Name=b ]
+  :=
+  LiteralExpr [STRING] [abcdefghij]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [0]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [0]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=a ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [0]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [0]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [4]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [5]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [5]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [6]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [0]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [0]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [TRUE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [FALSE]
+    ]
+    FunctionCall test.edit-distance-string-is-filterable@4[
+      Variable [ Name=b ]
+      LiteralExpr [LONG] [4]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [TRUE]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.3.ast
new file mode 100644
index 0000000..2f80a0b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_ints/edit-distance_ints.3.ast
@@ -0,0 +1,42 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [7]
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.edit-distance@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.3.ast
new file mode 100644
index 0000000..e59acfb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/edit-distance_strings/edit-distance_strings.3.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  LiteralExpr [STRING] [Nalini Venkatasubramanian]
+LetVariable [ Name=b ]
+  :=
+  LiteralExpr [STRING] [Nalini Wekatasupramanian]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.edit-distance@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.edit-distance@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.3.ast
new file mode 100644
index 0000000..6453100
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-edit-distance/fuzzyeq-edit-distance.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Set simfunction=edit-distance
+Set simthreshold=2
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=authors
+    ]
+    ~=
+    LiteralExpr [STRING] [Amihay Motro]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.3.ast
new file mode 100644
index 0000000..8a076b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/fuzzyeq-similarity-jaccard/fuzzyeq-similarity-jaccard.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Set simfunction=jaccard
+Set simthreshold=0.5f
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.word-tokens@1[
+      FieldAccessor [
+        Variable [ Name=paper ]
+        Field=title
+      ]
+    ]
+    ~=
+    FunctionCall test.word-tokens@1[
+      LiteralExpr [STRING] [Transactions for Cooperative Environments]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.3.ast
new file mode 100644
index 0000000..fbd95f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/prefix-len-jaccard/prefix-len-jaccard.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.prefix-len-jaccard@2[
+    LiteralExpr [LONG] [5]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+  FunctionCall test.prefix-len-jaccard@2[
+    LiteralExpr [LONG] [5]
+    LiteralExpr [FLOAT] [0.9]
+  ]
+  FunctionCall test.prefix-len-jaccard@2[
+    LiteralExpr [LONG] [10]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+  FunctionCall test.prefix-len-jaccard@2[
+    LiteralExpr [LONG] [10]
+    LiteralExpr [FLOAT] [0.9]
+  ]
+  FunctionCall test.prefix-len-jaccard@2[
+    LiteralExpr [LONG] [15]
+    LiteralExpr [FLOAT] [0.8]
+  ]
+  FunctionCall test.prefix-len-jaccard@2[
+    LiteralExpr [LONG] [15]
+    LiteralExpr [FLOAT] [0.9]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.3.ast
new file mode 100644
index 0000000..2b7864d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_ints/similarity-jaccard-check_ints.3.ast
@@ -0,0 +1,140 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [1]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [11]
+    LiteralExpr [LONG] [4]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [11]
+    LiteralExpr [LONG] [12]
+    LiteralExpr [LONG] [13]
+    LiteralExpr [LONG] [14]
+    LiteralExpr [LONG] [15]
+    LiteralExpr [LONG] [16]
+    LiteralExpr [LONG] [17]
+    LiteralExpr [LONG] [18]
+    LiteralExpr [LONG] [19]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [21]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [11]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+      LiteralExpr [FLOAT] [0.05]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+      LiteralExpr [FLOAT] [0.05]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.3.ast
new file mode 100644
index 0000000..846841a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_query/similarity-jaccard-check_query.3.ast
@@ -0,0 +1,36 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Environments for Cooperative Transactions]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.3.ast
new file mode 100644
index 0000000..3e87cf1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings/similarity-jaccard-check_strings.3.ast
@@ -0,0 +1,185 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [Efg]
+    LiteralExpr [STRING] [aBc]
+    LiteralExpr [STRING] [cdE]
+    LiteralExpr [STRING] [DEf]
+    LiteralExpr [STRING] [hIJ]
+    LiteralExpr [STRING] [IjK]
+    LiteralExpr [STRING] [BCD]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=g ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [zza]
+    LiteralExpr [STRING] [zzb]
+    LiteralExpr [STRING] [zzc]
+    LiteralExpr [STRING] [zwz]
+    LiteralExpr [STRING] [za]
+    LiteralExpr [STRING] [zbe]
+    LiteralExpr [STRING] [zer]
+    LiteralExpr [STRING] [zba]
+    LiteralExpr [STRING] [zfe]
+    LiteralExpr [STRING] [wab]
+  ]
+LetVariable [ Name=h ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=g ]
+      Variable [ Name=h ]
+      LiteralExpr [FLOAT] [0.05]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=h ]
+      Variable [ Name=g ]
+      LiteralExpr [FLOAT] [0.05]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=g ]
+      Variable [ Name=h ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=h ]
+      Variable [ Name=g ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.3.ast
new file mode 100644
index 0000000..8af77eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-check_strings_issue628/similarity-jaccard-check_strings_issue628.3.ast
@@ -0,0 +1,81 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=v1 ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [query]
+    LiteralExpr [STRING] [processing]
+    LiteralExpr [STRING] [in]
+    LiteralExpr [STRING] [multidatabase]
+    LiteralExpr [STRING] [systems]
+  ]
+LetVariable [ Name=v2 ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [query]
+    LiteralExpr [STRING] [processing]
+    LiteralExpr [STRING] [in]
+    LiteralExpr [STRING] [object]
+    LiteralExpr [STRING] [oriented]
+    LiteralExpr [STRING] [database]
+    LiteralExpr [STRING] [systems]
+  ]
+LetVariable [ Name=v3 ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [dynamic]
+    LiteralExpr [STRING] [query]
+    LiteralExpr [STRING] [optimization]
+    LiteralExpr [STRING] [and]
+    LiteralExpr [STRING] [query]
+    LiteralExpr [STRING] [processing]
+    LiteralExpr [STRING] [in]
+    LiteralExpr [STRING] [multidatabase]
+    LiteralExpr [STRING] [systems]
+    LiteralExpr [STRING] [1]
+  ]
+LetVariable [ Name=v4 ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [transaction]
+    LiteralExpr [STRING] [management]
+    LiteralExpr [STRING] [in]
+    LiteralExpr [STRING] [multidatabase]
+    LiteralExpr [STRING] [systems]
+  ]
+LetVariable [ Name=v5 ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [overview]
+    LiteralExpr [STRING] [of]
+    LiteralExpr [STRING] [multidatabase]
+    LiteralExpr [STRING] [transaction]
+    LiteralExpr [STRING] [management]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=v1 ]
+      Variable [ Name=v2 ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=v1 ]
+      Variable [ Name=v3 ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+    FunctionCall test.similarity-jaccard-check@3[
+      Variable [ Name=v4 ]
+      Variable [ Name=v5 ]
+      LiteralExpr [FLOAT] [0.5]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.ast
new file mode 100644
index 0000000..59e3f1a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix-check/similarity-jaccard-prefix-check.3.ast
@@ -0,0 +1,109 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.similarity-jaccard-prefix-check@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [1.0]
+  ]
+  FunctionCall test.similarity-jaccard-prefix-check@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+  FunctionCall test.similarity-jaccard-prefix-check@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.6]
+  ]
+  FunctionCall test.similarity-jaccard-prefix-check@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [9]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+  FunctionCall test.similarity-jaccard-prefix-check@6[
+    LiteralExpr [LONG] [4]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [2]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+  FunctionCall test.similarity-jaccard-prefix-check@6[
+    LiteralExpr [LONG] [4]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [4]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.33]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.ast
new file mode 100644
index 0000000..aceda8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-prefix/similarity-jaccard-prefix.3.ast
@@ -0,0 +1,109 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.similarity-jaccard-prefix@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [1.0]
+  ]
+  FunctionCall test.similarity-jaccard-prefix@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+  FunctionCall test.similarity-jaccard-prefix@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.6]
+  ]
+  FunctionCall test.similarity-jaccard-prefix@6[
+    LiteralExpr [LONG] [3]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [9]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+  FunctionCall test.similarity-jaccard-prefix@6[
+    LiteralExpr [LONG] [4]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [2]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+  FunctionCall test.similarity-jaccard-prefix@6[
+    LiteralExpr [LONG] [4]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [4]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [FLOAT] [0.33]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.ast
new file mode 100644
index 0000000..c4b1dbf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_ints/similarity-jaccard-sorted-check_ints.3.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [11]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.ast
new file mode 100644
index 0000000..d6f2a1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_query/similarity-jaccard-sorted-check_query.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Cooperative Transactions for Environments]
+  ]
+LetVariable [ Name=jacc ]
+  :=
+  FunctionCall test.similarity-jaccard-sorted-check@3[
+    Variable [ Name=paper_tokens ]
+    Variable [ Name=query_tokens ]
+    LiteralExpr [FLOAT] [0.5]
+  ]
+Where
+  IndexAccessor [
+    Variable [ Name=jacc ]
+    Index:     Variable [ Name=jacc ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.ast
new file mode 100644
index 0000000..647f261
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted-check_strings/similarity-jaccard-sorted-check_strings.3.ast
@@ -0,0 +1,137 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [jkl]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [Abc]
+    LiteralExpr [STRING] [bCd]
+    LiteralExpr [STRING] [cdE]
+    LiteralExpr [STRING] [DEf]
+    LiteralExpr [STRING] [eFG]
+    LiteralExpr [STRING] [HiJ]
+    LiteralExpr [STRING] [IJK]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [jkl]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.0]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+      LiteralExpr [FLOAT] [0.1]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+      LiteralExpr [FLOAT] [0.6]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+    FunctionCall test.similarity-jaccard-sorted-check@3[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+      LiteralExpr [FLOAT] [0.8]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.ast
new file mode 100644
index 0000000..ccf6b9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_ints/similarity-jaccard-sorted_ints.3.ast
@@ -0,0 +1,68 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [11]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.ast
new file mode 100644
index 0000000..3da839d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_query/similarity-jaccard-sorted_query.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Cooperative Transactions for Environments]
+  ]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=paper_tokens ]
+      Variable [ Name=query_tokens ]
+    ]
+    >=
+    LiteralExpr [DOUBLE] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.ast
new file mode 100644
index 0000000..061753a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard-sorted_strings/similarity-jaccard-sorted_strings.3.ast
@@ -0,0 +1,101 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [jkl]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [Abc]
+    LiteralExpr [STRING] [bCd]
+    LiteralExpr [STRING] [cdE]
+    LiteralExpr [STRING] [DEf]
+    LiteralExpr [STRING] [eFG]
+    LiteralExpr [STRING] [HiJ]
+    LiteralExpr [STRING] [IJK]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [jkl]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+    ]
+    FunctionCall test.similarity-jaccard-sorted@2[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.ast
new file mode 100644
index 0000000..2a62f96
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_ints/similarity-jaccard_ints.3.ast
@@ -0,0 +1,101 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [11]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [1]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [11]
+    LiteralExpr [LONG] [4]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.1.ast
new file mode 100644
index 0000000..a0ee7c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl DBLPType [
+  closed RecordType {
+    id : int64,
+    dblpid : string,
+    title : string,
+    authors : string,
+    misc : string
+  }
+]
+DatasetDecl DBLP(DBLPType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.3.ast
new file mode 100644
index 0000000..cdb4b9a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_query/similarity-jaccard_query.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=paper ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [DBLP]
+  ]
+  AS
+  Variable [ Name=paper ]
+]
+LetVariable [ Name=paper_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    FieldAccessor [
+      Variable [ Name=paper ]
+      Field=title
+    ]
+  ]
+LetVariable [ Name=query_tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    LiteralExpr [STRING] [Transactions for Cooperative Environments]
+  ]
+Where
+  OperatorExpr [
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=paper_tokens ]
+      Variable [ Name=query_tokens ]
+    ]
+    >=
+    LiteralExpr [FLOAT] [0.5]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.ast
new file mode 100644
index 0000000..8689182
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/similarity/similarity-jaccard_strings/similarity-jaccard_strings.3.ast
@@ -0,0 +1,134 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [jkl]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=g ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [Efg]
+    LiteralExpr [STRING] [aBc]
+    LiteralExpr [STRING] [cdE]
+    LiteralExpr [STRING] [DEf]
+    LiteralExpr [STRING] [hIJ]
+    LiteralExpr [STRING] [IjK]
+    LiteralExpr [STRING] [BCD]
+  ]
+LetVariable [ Name=h ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=g ]
+      Variable [ Name=h ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=h ]
+      Variable [ Name=g ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.ast
new file mode 100644
index 0000000..2559edc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+TypeDecl Tweet [
+  closed RecordType {
+    id : int64,
+    tweetid : int64,
+    loc : point,
+    time : datetime,
+    text : string
+  }
+]
+DatasetDecl TwitterData(Tweet) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast
new file mode 100644
index 0000000..e8b514c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.3.ast
@@ -0,0 +1,103 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cell]
+    :
+    Variable [ Name=c ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    Variable [ Name=num ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TwitterData]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+LetVariable [ Name=keywords ]
+  :=
+  LiteralExpr [STRING] [Allergies]
+LetVariable [ Name=region ]
+  :=
+  FunctionCall test.polygon@1[
+    LiteralExpr [STRING] [
+	33.80503407287759,-126.41235263538363 
+	44.9090773200516,-126.41235263538363 
+	44.9090773200516,-87.65258701038363 
+	33.80503407287759,-87.65258701038363]
+  ]
+Where
+  OperatorExpr [
+    FunctionCall test.spatial-intersect@2[
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=loc
+      ]
+      Variable [ Name=region ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=time
+      ]
+      >
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-05-15T00:00:00Z]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=time
+      ]
+      <
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2011-05-16T23:59:59Z]
+      ]
+    ]
+    and
+    FunctionCall test.contains@2[
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=text
+      ]
+      Variable [ Name=keywords ]
+    ]
+  ]
+Groupby
+  Variable [ Name=c ]
+  :=
+  FunctionCall test.spatial-cell@4[
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=loc
+    ]
+    FunctionCall test.create-point@2[
+      LiteralExpr [DOUBLE] [24.5]
+      NEGATIVE LiteralExpr [DOUBLE] [125.5]
+    ]
+    LiteralExpr [DOUBLE] [3.0]
+    LiteralExpr [DOUBLE] [3.0]
+  ]
+  With
+  Variable [ Name=region ]
+  Variable [ Name=keywords ]
+  Variable [ Name=t ]
+
+LetVariable [ Name=num ]
+  :=
+  FunctionCall test.count@1[
+    Variable [ Name=t ]
+  ]
+Orderby
+  Variable [ Name=num ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.1.ast
new file mode 100644
index 0000000..59c8cec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    loc : point
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.3.ast
new file mode 100644
index 0000000..4fae5b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/cell-aggregation/cell-aggregation.3.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+Query:
+LetVariable [ Name=grid ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [cell]
+        :
+        Variable [ Name=c ]
+      )
+      (
+        LiteralExpr [STRING] [count]
+        :
+        Variable [ Name=num ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [MyData]
+      ]
+      AS
+      Variable [ Name=o ]
+    ]
+    Groupby
+      Variable [ Name=c ]
+      :=
+      FunctionCall test.spatial-cell@4[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=loc
+        ]
+        FunctionCall test.create-point@2[
+          LiteralExpr [DOUBLE] [0.0]
+          LiteralExpr [DOUBLE] [0.0]
+        ]
+        LiteralExpr [DOUBLE] [5.0]
+        LiteralExpr [DOUBLE] [5.0]
+      ]
+      With
+      Variable [ Name=o ]
+      Variable [ Name=grid ]
+
+    LetVariable [ Name=num ]
+      :=
+      FunctionCall test.count@1[
+        Variable [ Name=o ]
+      ]
+    Orderby
+      Variable [ Name=num ]
+      ASC
+
+  )
+SELECT ELEMENT [
+Variable [ Name=g ]
+]
+FROM [  Variable [ Name=grid ]
+  AS
+  Variable [ Name=g ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.3.ast
new file mode 100644
index 0000000..ffa8c05
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle-intersect-circle/circle-intersect-circle.3.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FunctionCall test.create-circle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [0.0]
+      ]
+      LiteralExpr [DOUBLE] [5.0]
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=circle
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.3.ast
new file mode 100644
index 0000000..7a462d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/circle_accessor/circle_accessor.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [circle-radius]
+    :
+    FunctionCall test.get-radius@1[
+      FunctionCall test.create-circle@2[
+        FunctionCall test.create-point@2[
+          LiteralExpr [DOUBLE] [6.0]
+          LiteralExpr [DOUBLE] [3.0]
+        ]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circle-center]
+    :
+    FunctionCall test.get-center@1[
+      FunctionCall test.create-circle@2[
+        FunctionCall test.create-point@2[
+          LiteralExpr [DOUBLE] [6.0]
+          LiteralExpr [DOUBLE] [3.0]
+        ]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.1.ast
new file mode 100644
index 0000000..8f1e691
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.1.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+TypeDecl SpatialType [
+  open RecordType {
+    id : int64,
+    point : point,
+    line1 : line,
+    poly1 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(SpatialType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.3.ast
new file mode 100644
index 0000000..86fa211
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/create-rtree-index/create-rtree-index.3.ast
@@ -0,0 +1,21 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FieldAccessor [
+  Variable [ Name=a ]
+  Field=id
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.3.ast
new file mode 100644
index 0000000..b1f61da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/distance-between-points/distance-between-points.3.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [distance]
+    :
+    Variable [ Name=distance ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+LetVariable [ Name=distance ]
+  :=
+  FunctionCall test.spatial-distance@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-point@2[
+      LiteralExpr [DOUBLE] [0.0]
+      LiteralExpr [DOUBLE] [0.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.3.ast
new file mode 100644
index 0000000..1a927eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-circle/line-intersect-circle.3.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line1
+    ]
+    FunctionCall test.create-circle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [0.0]
+      ]
+      LiteralExpr [DOUBLE] [5.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.3.ast
new file mode 100644
index 0000000..245b3cb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-line/line-intersect-line.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line1
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line2
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.3.ast
new file mode 100644
index 0000000..e9d363d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-polygon/line-intersect-polygon.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line1
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly1
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.3.ast
new file mode 100644
index 0000000..7812f4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line-intersect-rectangle/line-intersect-rectangle.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line1
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=rec
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast
new file mode 100644
index 0000000..08f656a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/line_accessor/line_accessor.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+LetVariable [ Name=line ]
+  :=
+  FunctionCall test.create-line@2[
+    FunctionCall test.create-point@2[
+      LiteralExpr [DOUBLE] [100.6]
+      LiteralExpr [DOUBLE] [999.4]
+    ]
+    FunctionCall test.create-point@2[
+      NEGATIVE LiteralExpr [DOUBLE] [872.0]
+      NEGATIVE LiteralExpr [DOUBLE] [876.9]
+    ]
+  ]
+LetVariable [ Name=line_list ]
+  :=
+  FunctionCall test.get-points@1[
+    Variable [ Name=line ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=p ]
+]
+FROM [  Variable [ Name=line_list ]
+  AS
+  Variable [ Name=p ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.3.ast
new file mode 100644
index 0000000..c754d98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-equals-point/point-equals-point.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-point@2[
+      LiteralExpr [DOUBLE] [5.0]
+      LiteralExpr [DOUBLE] [1.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.3.ast
new file mode 100644
index 0000000..940a203
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-circle/point-in-circle.3.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-circle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [0.0]
+      ]
+      LiteralExpr [DOUBLE] [5.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.3.ast
new file mode 100644
index 0000000..8bcaa53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-polygon/point-in-polygon.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly1
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.3.ast
new file mode 100644
index 0000000..796923a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-in-rectangle/point-in-rectangle.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=rec
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.3.ast
new file mode 100644
index 0000000..94574c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point-on-line/point-on-line.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=line1
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.3.ast
new file mode 100644
index 0000000..6d5fe7e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/point_accessor/point_accessor.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [x-coordinate]
+    :
+    FunctionCall test.get-x@1[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [2.3]
+        LiteralExpr [DOUBLE] [5.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [y-coordinate]
+    :
+    FunctionCall test.get-y@1[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [2.3]
+        LiteralExpr [DOUBLE] [5.0]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.3.ast
new file mode 100644
index 0000000..d597bb2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-circle/polygon-intersect-circle.3.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly1
+    ]
+    FunctionCall test.create-circle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [6.0]
+        LiteralExpr [DOUBLE] [3.0]
+      ]
+      LiteralExpr [DOUBLE] [1.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.3.ast
new file mode 100644
index 0000000..aa394ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-polygon/polygon-intersect-polygon.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly1
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly2
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.3.ast
new file mode 100644
index 0000000..a9fa6b2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon-intersect-rectangle/polygon-intersect-rectangle.3.ast
@@ -0,0 +1,38 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=poly1
+    ]
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=rec
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.3.ast
new file mode 100644
index 0000000..fec7111
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/polygon_accessor/polygon_accessor.3.ast
@@ -0,0 +1,28 @@
+DataverseUse test
+Query:
+LetVariable [ Name=polygon ]
+  :=
+  FunctionCall test.create-polygon@1[
+    OrderedListConstructor [
+      LiteralExpr [DOUBLE] [1.0]
+      LiteralExpr [DOUBLE] [1.0]
+      LiteralExpr [DOUBLE] [2.0]
+      LiteralExpr [DOUBLE] [2.0]
+      LiteralExpr [DOUBLE] [3.0]
+      LiteralExpr [DOUBLE] [3.0]
+      LiteralExpr [DOUBLE] [4.0]
+      LiteralExpr [DOUBLE] [4.0]
+    ]
+  ]
+LetVariable [ Name=polygon_list ]
+  :=
+  FunctionCall test.get-points@1[
+    Variable [ Name=polygon ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=p ]
+]
+FROM [  Variable [ Name=polygon_list ]
+  AS
+  Variable [ Name=p ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.3.ast
new file mode 100644
index 0000000..505572f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-circle/rectangle-intersect-circle.3.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=rec
+    ]
+    FunctionCall test.create-circle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [4.1]
+        LiteralExpr [DOUBLE] [4.1]
+      ]
+      LiteralExpr [DOUBLE] [1.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.1.ast
new file mode 100644
index 0000000..0ba060e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int64,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast
new file mode 100644
index 0000000..5043ef9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle-intersect-rectangle/rectangle-intersect-rectangle.3.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=rec
+    ]
+    FunctionCall test.create-rectangle@2[
+      FunctionCall test.create-point@2[
+        LiteralExpr [DOUBLE] [4.5]
+        LiteralExpr [DOUBLE] [9.0]
+      ]
+      FunctionCall test.create-point@2[
+        NEGATIVE LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [5.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.3.ast
new file mode 100644
index 0000000..c9af06a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/rectangle_accessor/rectangle_accessor.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+LetVariable [ Name=rectangle ]
+  :=
+  FunctionCall test.create-rectangle@2[
+    FunctionCall test.create-point@2[
+      LiteralExpr [DOUBLE] [9.2]
+      LiteralExpr [DOUBLE] [49.0]
+    ]
+    FunctionCall test.create-point@2[
+      LiteralExpr [DOUBLE] [77.8]
+      LiteralExpr [DOUBLE] [111.1]
+    ]
+  ]
+LetVariable [ Name=rectangle_list ]
+  :=
+  FunctionCall test.get-points@1[
+    Variable [ Name=rectangle ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=p ]
+]
+FROM [  Variable [ Name=rectangle_list ]
+  AS
+  Variable [ Name=p ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.1.ast
new file mode 100644
index 0000000..6a32856
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl MyRecord [
+  open RecordType {
+    id : int32,
+    point : point,
+    kwds : string
+  }
+]
+DatasetDecl MyData(MyRecord)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.3.ast
new file mode 100644
index 0000000..72d824e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/spatial/spatial-area/spatial-area.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [polygonArea]
+    :
+    FunctionCall test.spatial-area@1[
+      FunctionCall test.create-polygon@1[
+        OrderedListConstructor [
+          LiteralExpr [DOUBLE] [1.0]
+          LiteralExpr [DOUBLE] [1.0]
+          LiteralExpr [DOUBLE] [1.0]
+          LiteralExpr [DOUBLE] [4.0]
+          LiteralExpr [DOUBLE] [3.0]
+          LiteralExpr [DOUBLE] [4.0]
+          LiteralExpr [DOUBLE] [3.0]
+          LiteralExpr [DOUBLE] [1.0]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [circleArea]
+    :
+    FunctionCall test.spatial-area@1[
+      FunctionCall test.create-circle@2[
+        FunctionCall test.create-point@2[
+          LiteralExpr [DOUBLE] [0.0]
+          LiteralExpr [DOUBLE] [0.0]
+        ]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [rectangleArea]
+    :
+    FunctionCall test.spatial-area@1[
+      FunctionCall test.create-rectangle@2[
+        FunctionCall test.create-point@2[
+          LiteralExpr [DOUBLE] [0.0]
+          LiteralExpr [DOUBLE] [5.0]
+        ]
+        FunctionCall test.create-point@2[
+          LiteralExpr [DOUBLE] [8.0]
+          LiteralExpr [DOUBLE] [8.0]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.3.ast
new file mode 100644
index 0000000..fefd6cf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string1/codepoint-to-string1.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.codepoint-to-string@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [20013]
+        LiteralExpr [LONG] [25991]
+        LiteralExpr [LONG] [23383]
+        LiteralExpr [LONG] [31526]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.3.ast
new file mode 100644
index 0000000..84548d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/codepoint-to-string2/codepoint-to-string2.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.codepoint-to-string@1[
+      OrderedListConstructor [
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.codepoint-to-string@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [97]
+        LiteralExpr [LONG] [98]
+        LiteralExpr [LONG] [99]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.3.ast
new file mode 100644
index 0000000..e1831a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_01/concat_01.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [aa]
+        LiteralExpr [STRING] [25991]
+        LiteralExpr [STRING] [bb]
+        LiteralExpr [STRING] [31526]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.3.ast
new file mode 100644
index 0000000..00fcae6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_02/concat_02.3.ast
@@ -0,0 +1,33 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [a]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [b]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [NULL]
+        LiteralExpr [STRING] [foo]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [foo]
+        LiteralExpr [NULL]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.3.ast
new file mode 100644
index 0000000..3658912
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/concat_03/concat_03.3.ast
@@ -0,0 +1,64 @@
+DataverseUse test
+Query:
+LetVariable [ Name=k ]
+  :=
+  OrderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [a]
+        :
+        LiteralExpr [LONG] [1]
+      )
+      (
+        LiteralExpr [STRING] [b]
+        :
+        LiteralExpr [STRING] [hello]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [a]
+        :
+        LiteralExpr [LONG] [2]
+      )
+      (
+        LiteralExpr [STRING] [b]
+        :
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [k]
+            :
+            OrderedListConstructor [
+              LiteralExpr [LONG] [1]
+              LiteralExpr [LONG] [2]
+              LiteralExpr [LONG] [2]
+            ]
+          )
+        ]
+      )
+    ]
+  ]
+SELECT ELEMENT [
+FunctionCall test.string-concat@1[
+  OrderedListConstructor [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=b
+    ]
+    LiteralExpr [STRING] [ world]
+  ]
+]
+]
+FROM [  Variable [ Name=k ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=a
+    ]
+    =
+    LiteralExpr [LONG] [1]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.3.ast
new file mode 100644
index 0000000..8c4d21b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/constructor/constructor.3.ast
@@ -0,0 +1,27 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  LiteralExpr [LONG] [1]
+LetVariable [ Name=b ]
+  :=
+  LiteralExpr [LONG] [2]
+LetVariable [ Name=c ]
+  :=
+  LiteralExpr [STRING] [c]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    Variable [ Name=a ]
+    Variable [ Name=b ]
+    Variable [ Name=c ]
+  ]
+SELECT ELEMENT [
+FunctionCall test.string@1[
+  Variable [ Name=x ]
+]
+]
+FROM [  Variable [ Name=d ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.3.ast
new file mode 100644
index 0000000..0d7d8d2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/contains_01/contains_01.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.contains@2[
+    Variable [ Name=x ]
+    LiteralExpr [STRING] [ofo]
+  ]
+  FunctionCall test.contains@2[
+    Variable [ Name=y ]
+    LiteralExpr [STRING] [ofo]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [foofoo]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  OrderedListConstructor [
+    LiteralExpr [STRING] [barbar]
+  ]
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.1.ast
new file mode 100644
index 0000000..7ebd13a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    cpt : OrderedList [int32]
+
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.3.ast
new file mode 100644
index 0000000..5c4a2b3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr01/cpttostr01.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.codepoint-to-string@1[
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=cpt
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.3.ast
new file mode 100644
index 0000000..2304c31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr02/cpttostr02.3.ast
@@ -0,0 +1,104 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    FunctionCall null.codepoint-to-string@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [65]
+        LiteralExpr [LONG] [66]
+        LiteralExpr [LONG] [67]
+        LiteralExpr [LONG] [68]
+        LiteralExpr [LONG] [69]
+        LiteralExpr [LONG] [70]
+        LiteralExpr [LONG] [71]
+        LiteralExpr [LONG] [72]
+        LiteralExpr [LONG] [73]
+        LiteralExpr [LONG] [74]
+        LiteralExpr [LONG] [75]
+        LiteralExpr [LONG] [76]
+        LiteralExpr [LONG] [77]
+        LiteralExpr [LONG] [78]
+        LiteralExpr [LONG] [79]
+        LiteralExpr [LONG] [80]
+        LiteralExpr [LONG] [81]
+        LiteralExpr [LONG] [82]
+        LiteralExpr [LONG] [83]
+        LiteralExpr [LONG] [84]
+        LiteralExpr [LONG] [85]
+        LiteralExpr [LONG] [86]
+        LiteralExpr [LONG] [87]
+        LiteralExpr [LONG] [88]
+        LiteralExpr [LONG] [89]
+        LiteralExpr [LONG] [90]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c2]
+    :
+    FunctionCall null.codepoint-to-string@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [97]
+        LiteralExpr [LONG] [98]
+        LiteralExpr [LONG] [99]
+        LiteralExpr [LONG] [100]
+        LiteralExpr [LONG] [101]
+        LiteralExpr [LONG] [102]
+        LiteralExpr [LONG] [103]
+        LiteralExpr [LONG] [104]
+        LiteralExpr [LONG] [105]
+        LiteralExpr [LONG] [106]
+        LiteralExpr [LONG] [107]
+        LiteralExpr [LONG] [108]
+        LiteralExpr [LONG] [109]
+        LiteralExpr [LONG] [110]
+        LiteralExpr [LONG] [111]
+        LiteralExpr [LONG] [112]
+        LiteralExpr [LONG] [113]
+        LiteralExpr [LONG] [114]
+        LiteralExpr [LONG] [115]
+        LiteralExpr [LONG] [116]
+        LiteralExpr [LONG] [117]
+        LiteralExpr [LONG] [118]
+        LiteralExpr [LONG] [119]
+        LiteralExpr [LONG] [120]
+        LiteralExpr [LONG] [121]
+        LiteralExpr [LONG] [122]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c3]
+    :
+    FunctionCall null.codepoint-to-string@1[
+      OrderedListConstructor [
+        LiteralExpr [LONG] [33]
+        LiteralExpr [LONG] [34]
+        LiteralExpr [LONG] [35]
+        LiteralExpr [LONG] [36]
+        LiteralExpr [LONG] [37]
+        LiteralExpr [LONG] [38]
+        LiteralExpr [LONG] [39]
+        LiteralExpr [LONG] [40]
+        LiteralExpr [LONG] [41]
+        LiteralExpr [LONG] [42]
+        LiteralExpr [LONG] [43]
+        LiteralExpr [LONG] [44]
+        LiteralExpr [LONG] [45]
+        LiteralExpr [LONG] [46]
+        LiteralExpr [LONG] [47]
+        LiteralExpr [LONG] [48]
+        LiteralExpr [LONG] [49]
+        LiteralExpr [LONG] [50]
+        LiteralExpr [LONG] [51]
+        LiteralExpr [LONG] [52]
+        LiteralExpr [LONG] [53]
+        LiteralExpr [LONG] [54]
+        LiteralExpr [LONG] [55]
+        LiteralExpr [LONG] [63]
+        LiteralExpr [LONG] [64]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.3.ast
new file mode 100644
index 0000000..5da3631
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/cpttostr04/cpttostr04.3.ast
@@ -0,0 +1,12 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    FunctionCall null.codepoint-to-string@1[
+      FunctionCall null.string-to-codepoint@1[
+        LiteralExpr [STRING] [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.3.ast
new file mode 100644
index 0000000..73188fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with1/end-with1.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [STRING] [werld]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.3.ast
new file mode 100644
index 0000000..5ebbce3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with2/end-with2.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [STRING] [ world]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.3.ast
new file mode 100644
index 0000000..b0076f0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with3/end-with3.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] [ends]
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.3.ast
new file mode 100644
index 0000000..96ce926
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with4/end-with4.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] [ends]
+      LiteralExpr [STRING] [ss]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.3.ast
new file mode 100644
index 0000000..53d25d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/end-with5/end-with5.3.ast
@@ -0,0 +1,52 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] [ends]
+      LiteralExpr [STRING] [s]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] [start]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.end-with@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.3.ast
new file mode 100644
index 0000000..7996206
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/ends-with_01/ends-with_01.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.ends-with@2[
+    Variable [ Name=x ]
+    LiteralExpr [STRING] [ar]
+  ]
+  FunctionCall test.ends-with@2[
+    Variable [ Name=y ]
+    LiteralExpr [STRING] [ar]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [foofoo]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  OrderedListConstructor [
+    LiteralExpr [STRING] [barbar]
+  ]
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.3.ast
new file mode 100644
index 0000000..266a570
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith02/endwith02.3.ast
@@ -0,0 +1,43 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.end-with@2[
+      LiteralExpr [STRING] [aBCDEFghIa]
+      FunctionCall null.codepoint-to-string@1[
+        OrderedListConstructor [
+          LiteralExpr [LONG] [41]
+        ]
+      ]
+    ]
+    FunctionCall null.end-with@2[
+      LiteralExpr [STRING] [AbCDEFghIA]
+      FunctionCall null.codepoint-to-string@1[
+        OrderedListConstructor [
+          LiteralExpr [LONG] [41]
+        ]
+      ]
+    ]
+    FunctionCall null.end-with@2[
+      LiteralExpr [STRING] [AbCdEfGhIjKlMnOpQrStUvWxYz]
+      LiteralExpr [STRING] [xYz]
+    ]
+    FunctionCall null.end-with@2[
+      LiteralExpr [STRING] [abcdef]
+      FunctionCall null.lowercase@1[
+        LiteralExpr [STRING] [ABCDEf]
+      ]
+    ]
+    FunctionCall null.end-with@2[
+      LiteralExpr [STRING] [abcdef]
+      LiteralExpr [STRING] [abcdef]
+    ]
+    FunctionCall null.end-with@2[
+      LiteralExpr [STRING] [abcdef123]
+      LiteralExpr [STRING] [ef123]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.1.ast
new file mode 100644
index 0000000..0637761
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name : string
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.3.ast
new file mode 100644
index 0000000..41c80a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/endwith03/endwith03.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  FunctionCall test.end-with@2[
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=name
+    ]
+    LiteralExpr [STRING] [Jones]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/escapes01/escapes01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/escapes01/escapes01.1.ast
new file mode 100644
index 0000000..0d7c3bc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/escapes01/escapes01.1.ast
@@ -0,0 +1,10 @@
+Query:
+SELECT ELEMENT [
+FunctionCall null.string-concat@1[
+  OrderedListConstructor [
+    LiteralExpr [STRING] [12
+3	4
567"8]
+    LiteralExpr [STRING] ['9]
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/escapes02/escapes02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/escapes02/escapes02.1.ast
new file mode 100644
index 0000000..ffb8d5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/escapes02/escapes02.1.ast
Binary files differ
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.3.ast
new file mode 100644
index 0000000..375ab2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_01/length_01.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-length@1[
+      LiteralExpr [STRING] [hellow]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.string-length@1[
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.string-length@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.3.ast
new file mode 100644
index 0000000..0381cea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/length_02/length_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.string-length@1[
+  Variable [ Name=x ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [ten]
+    LiteralExpr [STRING] [twenty]
+    LiteralExpr [STRING] [thirty]
+    LiteralExpr [STRING] [forty]
+    LiteralExpr [STRING] [fifty]
+    LiteralExpr [STRING] [sixty]
+    LiteralExpr [STRING] [seventy]
+    LiteralExpr [STRING] [ninety]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.3.ast
new file mode 100644
index 0000000..ca602eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_01/like_01.3.ast
@@ -0,0 +1,14 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.like@2[
+    LiteralExpr [STRING] [A6BBB]
+    LiteralExpr [STRING] [_6%]
+  ]
+  FunctionCall test.like@2[
+    LiteralExpr [STRING] [A8BBB]
+    LiteralExpr [STRING] [_6%]
+  ]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.3.ast
new file mode 100644
index 0000000..6cf5fca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/like_null/like_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [field1]
+    :
+    FunctionCall test.like@2[
+      LiteralExpr [STRING] [A8BBB]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [field2]
+    :
+    FunctionCall test.like@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [_6%]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.3.ast
new file mode 100644
index 0000000..03c38a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/lowercase/lowercase.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.lowercase@1[
+      LiteralExpr [STRING] [HEllow]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.lowercase@1[
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.lowercase@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.3.ast
new file mode 100644
index 0000000..cd2490b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches02/matches02.3.ast
@@ -0,0 +1,85 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c3]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Hello World]
+      LiteralExpr [STRING] [Hello World]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c4]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Asterix for Dummies]
+      LiteralExpr [STRING] [Asterix for Dummies]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c5]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [semistructured data]
+      FunctionCall null.lowercase@1[
+        LiteralExpr [STRING] [SEMISTRUCTURED DATA]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c6]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Mega Living!]
+      LiteralExpr [STRING] [Mega]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c7]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Mega Living!]
+      LiteralExpr [STRING] [ving!]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c8]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Mega Living!]
+      LiteralExpr [STRING] [ ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c9]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Mega Living!]
+      LiteralExpr [STRING] [a l]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c10]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Mega Living!]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c11]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [ ]
+      LiteralExpr [STRING] [ ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c12]
+    :
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [aaaa]
+      LiteralExpr [STRING] [aaaaa]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.3.ast
new file mode 100644
index 0000000..f8bfc44
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches03/matches03.3.ast
@@ -0,0 +1,61 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [1234567890]
+      LiteralExpr [STRING] [[^a-z]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [1234567890]
+      LiteralExpr [STRING] [[^a-zA-Z]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghABCDEFGH]
+      LiteralExpr [STRING] [[^a-zA-Z]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[^a-zA-Z]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[^A-Z]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[^a-z]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[^0-9]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[0-9]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [adefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[a-z&&[^bc]]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
+      LiteralExpr [STRING] [[a-z&&[^bc]]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [bc]
+      LiteralExpr [STRING] [[a-z&&[^bc]]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [mnop]
+      LiteralExpr [STRING] [[a-z&&[^m-p]]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdmnop]
+      LiteralExpr [STRING] [[a-z&&[^m-p]]]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.3.ast
new file mode 100644
index 0000000..48f202f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches04/matches04.3.ast
@@ -0,0 +1,37 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [UCI UCI UCI UCI UCI UCI]
+      LiteralExpr [STRING] [[UCI{6}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [UCI UCI UCI UCI UCI UCI]
+      LiteralExpr [STRING] [[UCI{3,6}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [UCI UCI UCI UCI UCI UCI]
+      LiteralExpr [STRING] [[UCI{7}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [UCI UCI UCI UCI UCI UCI]
+      LiteralExpr [STRING] [[UCI{1}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [UCI UCI UCI]
+      LiteralExpr [STRING] [[UCI+]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [false]
+      LiteralExpr [STRING] [[true|false]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [YX]
+      LiteralExpr [STRING] [[XY]]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.1.ast
new file mode 100644
index 0000000..ca04279
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType1 [
+  open RecordType {
+    fname : string,
+    lname : string,
+    id : int64
+  }
+]
+DatasetDecl testds1(TestType1) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.3.ast
new file mode 100644
index 0000000..ea963e9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches05/matches05.3.ast
@@ -0,0 +1,29 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds1]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  FunctionCall test.matches@2[
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=fname
+    ]
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=lname
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.3.ast
new file mode 100644
index 0000000..2bae6ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches06/matches06.3.ast
@@ -0,0 +1,73 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [mnop]
+      LiteralExpr [STRING] [.]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefABCDEF]
+      LiteralExpr [STRING] [/d]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [12345]
+      LiteralExpr [STRING] [\d]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefGHIJK]
+      LiteralExpr [STRING] [\D]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [       ]
+      LiteralExpr [STRING] [\s]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [       ]
+      LiteralExpr [STRING] [\S]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [Welcome to pattern matching!]
+      LiteralExpr [STRING] [[a-zA-Z_0-9]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [!@#$%^&*()]
+      LiteralExpr [STRING] [[a-zA-Z_0-9]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [!@#$%^&*()]
+      LiteralExpr [STRING] [[^\W]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [!@#$%^&*]
+      LiteralExpr [STRING] [[^\w]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [0xffff]
+      LiteralExpr [STRING] [[\p{XDigit}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [FFFFFFFF]
+      LiteralExpr [STRING] [[\p{XDigit}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [abcdefgh]
+      LiteralExpr [STRING] [[\p{javaLowerCase}]]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [ABCDEF]
+      LiteralExpr [STRING] [[\p{javaLowerCase}]]
+    ]
+    FunctionCall null.matches@2[
+      FunctionCall null.codepoint-to-string@1[
+        OrderedListConstructor [
+          LiteralExpr [LONG] [163]
+        ]
+      ]
+      LiteralExpr [STRING] [[\p{Sc}]]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.3.ast
new file mode 100644
index 0000000..083dc03
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches1/matches1.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@2[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [bra]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.3.ast
new file mode 100644
index 0000000..3ccd271
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches11/matches11.3.ast
@@ -0,0 +1,29 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [hello]
+      LiteralExpr [NULL]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [hello]
+      LiteralExpr [STRING] [helllo]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [hello]
+      LiteralExpr [STRING] [ ]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [hello]
+    ]
+    FunctionCall null.matches@2[
+      LiteralExpr [STRING] [hello]
+      LiteralExpr [STRING] [[^a-z]]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.3.ast
new file mode 100644
index 0000000..5bc68c9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches2/matches2.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@2[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [^a.*a$]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.3.ast
new file mode 100644
index 0000000..bca016e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches21/matches21.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@3[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [Bra]
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.3.ast
new file mode 100644
index 0000000..29cd657
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches22/matches22.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@3[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [Bra]
+      LiteralExpr [STRING] [i]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.3.ast
new file mode 100644
index 0000000..2510066
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches23/matches23.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@3[
+      LiteralExpr [STRING] [helloworld]
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [STRING] [x]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.3.ast
new file mode 100644
index 0000000..198de67
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matches3/matches3.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@2[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [^bra]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.3.ast
new file mode 100644
index 0000000..f719453
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/matchesnull/matchesnull.3.ast
@@ -0,0 +1,55 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.matches@2[
+      LiteralExpr [STRING] [helloworld]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.matches@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.matches@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    FunctionCall test.matches@3[
+      LiteralExpr [STRING] [helloworld]
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    FunctionCall test.matches@3[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [i]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    FunctionCall test.matches@3[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.3.ast
new file mode 100644
index 0000000..1f92865
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace1/replace1.3.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.replace@3[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [a]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.replace@3[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [a(.)]
+      LiteralExpr [STRING] [a$1$1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.replace@3[
+      LiteralExpr [STRING] [darted]
+      LiteralExpr [STRING] [^(.*?)d(.*)$]
+      LiteralExpr [STRING] [$1c$2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.3.ast
new file mode 100644
index 0000000..48dd866
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace2/replace2.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.replace@3[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [bra]
+      LiteralExpr [STRING] [*]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.3.ast
new file mode 100644
index 0000000..c162e62
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace21/replace21.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [Bra]
+      LiteralExpr [STRING] [kkk]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [Bra]
+      LiteralExpr [STRING] [kkk]
+      LiteralExpr [STRING] [i]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [helloworld]
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [STRING] [kkk]
+      LiteralExpr [STRING] [x]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.3.ast
new file mode 100644
index 0000000..7469d43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace22/replace22.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [bra]
+      LiteralExpr [STRING] [XXX]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [STRING] [XxXx]
+      LiteralExpr [STRING] [x]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [bra]
+      LiteralExpr [STRING] [XXX]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [XXX]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [Bra]
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [i]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [Bra]
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] [i]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    FunctionCall test.replace@4[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] [XXX]
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.3.ast
new file mode 100644
index 0000000..d9f2c0f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/replace3/replace3.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.replace@3[
+      LiteralExpr [STRING] [abracadabra]
+      LiteralExpr [STRING] [a.*a]
+      LiteralExpr [STRING] [*]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.3.ast
new file mode 100644
index 0000000..b968f1b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with1/start-with1.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] [start]
+      LiteralExpr [STRING] [st]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.3.ast
new file mode 100644
index 0000000..13d5be4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with2/start-with2.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] [start]
+      LiteralExpr [STRING] [t]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.3.ast
new file mode 100644
index 0000000..b321a57
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with3/start-with3.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] [start]
+      LiteralExpr [STRING] [start]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.3.ast
new file mode 100644
index 0000000..5cd1e1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with4/start-with4.3.ast
@@ -0,0 +1,52 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [f1]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] [start]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f2]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] [start]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f3]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f4]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f5]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [f6]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.3.ast
new file mode 100644
index 0000000..e96b937
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/start-with5/start-with5.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.start-with@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] [s]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.3.ast
new file mode 100644
index 0000000..6bc99d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/starts-with_01/starts-with_01.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+OrderedListConstructor [
+  FunctionCall test.starts-with@2[
+    Variable [ Name=x ]
+    LiteralExpr [STRING] [ba]
+  ]
+  FunctionCall test.starts-with@2[
+    Variable [ Name=y ]
+    LiteralExpr [STRING] [ba]
+  ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [foofoo]
+  ]
+  AS
+  Variable [ Name=x ]
+,
+  OrderedListConstructor [
+    LiteralExpr [STRING] [barbar]
+  ]
+  AS
+  Variable [ Name=y ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.3.ast
new file mode 100644
index 0000000..9f525d0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/startwith02/startwith02.3.ast
@@ -0,0 +1,77 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [Hello]
+      LiteralExpr [STRING] [H]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [Hello]
+      FunctionCall null.lowercase@1[
+        LiteralExpr [STRING] [He]
+      ]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [Hello]
+      LiteralExpr [STRING] []
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [Hello]
+      LiteralExpr [STRING] [ ]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [Hello]
+      LiteralExpr [NULL]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [abcdef]
+      FunctionCall null.lowercase@1[
+        LiteralExpr [STRING] [ABCDEf]
+      ]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [abcdef]
+      LiteralExpr [STRING] [abcdef]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [abcdef]
+      LiteralExpr [STRING] [abc ]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [abc\tdef]
+      LiteralExpr [STRING] [abc\t]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [ abcdef]
+      LiteralExpr [STRING] [abc]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [0x1FF]
+      LiteralExpr [STRING] [0]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [<ID>]
+      LiteralExpr [STRING] [<]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [aBCDEFghI]
+      FunctionCall null.codepoint-to-string@1[
+        OrderedListConstructor [
+          LiteralExpr [LONG] [41]
+        ]
+      ]
+    ]
+    FunctionCall null.start-with@2[
+      LiteralExpr [STRING] [AbCDEFghI]
+      FunctionCall null.codepoint-to-string@1[
+        OrderedListConstructor [
+          LiteralExpr [LONG] [41]
+        ]
+      ]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.1.ast
new file mode 100644
index 0000000..9f4327a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    fname : string,
+    lname : string
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.3.ast
new file mode 100644
index 0000000..7d1aceb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat01/strconcat01.3.ast
@@ -0,0 +1,35 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [Full Name]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=fname
+        ]
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=lname
+        ]
+      ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.3.ast
new file mode 100644
index 0000000..364d6f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strconcat02/strconcat02.3.ast
@@ -0,0 +1,55 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.string-concat@1[
+      OrderedListConstructor [
+        FunctionCall null.codepoint-to-string@1[
+          FunctionCall null.string-to-codepoint@1[
+            LiteralExpr [STRING] [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]
+          ]
+        ]
+        FunctionCall null.codepoint-to-string@1[
+          FunctionCall null.string-to-codepoint@1[
+            LiteralExpr [STRING] [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]
+          ]
+        ]
+        FunctionCall null.codepoint-to-string@1[
+          FunctionCall null.string-to-codepoint@1[
+            LiteralExpr [STRING] [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]
+          ]
+        ]
+      ]
+    ]
+    FunctionCall null.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [ ]
+        LiteralExpr [STRING] [a]
+        LiteralExpr [STRING] [b]
+        LiteralExpr [STRING] [  ]
+        LiteralExpr [STRING] [c]
+        LiteralExpr [STRING] [d]
+        LiteralExpr [STRING] [e]
+        LiteralExpr [STRING] [f]
+        LiteralExpr [STRING] [g]
+        LiteralExpr [STRING] [p]
+        LiteralExpr [STRING] [o]
+        LiteralExpr [STRING] [q]
+        LiteralExpr [STRING] [r]
+        LiteralExpr [STRING] [s]
+        LiteralExpr [STRING] [t]
+        LiteralExpr [STRING] [ ]
+      ]
+    ]
+    FunctionCall null.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [This is a test]
+        LiteralExpr [STRING] [and all tests must pass]
+        LiteralExpr [STRING] [and life is good...]
+      ]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.3.ast
new file mode 100644
index 0000000..7584bf9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-concat1/string-concat1.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-concat@1[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [aa]
+        LiteralExpr [STRING] [25991]
+        LiteralExpr [STRING] [bb]
+        LiteralExpr [STRING] [31526]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.3.ast
new file mode 100644
index 0000000..1377e83
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal1/string-equal1.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [STRING] [test]
+      LiteralExpr [STRING] [tess]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.3.ast
new file mode 100644
index 0000000..ecb7764
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal2/string-equal2.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [STRING] [test]
+      LiteralExpr [STRING] [test]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.3.ast
new file mode 100644
index 0000000..87c8327
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal3/string-equal3.3.ast
@@ -0,0 +1,13 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [STRING] [test11]
+      LiteralExpr [STRING] [test]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.3.ast
new file mode 100644
index 0000000..5eafec6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-equal4/string-equal4.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    FunctionCall test.string-equal@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.3.ast
new file mode 100644
index 0000000..e8946c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-join1/string-join1.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result0]
+    :
+    FunctionCall test.string-join@2[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [aa]
+        LiteralExpr [STRING] [25991]
+        LiteralExpr [STRING] [bb]
+        LiteralExpr [STRING] [31526]
+      ]
+      LiteralExpr [STRING] [::]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-join@2[
+      OrderedListConstructor [
+        LiteralExpr [STRING] [aa]
+        LiteralExpr [STRING] [25991]
+        LiteralExpr [STRING] [bb]
+        LiteralExpr [STRING] [31526]
+      ]
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.3.ast
new file mode 100644
index 0000000..35813f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint/string-to-codepoint.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-to-codepoint@1[
+      LiteralExpr [STRING] [abcd]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.3.ast
new file mode 100644
index 0000000..f702769
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint1/string-to-codepoint1.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-to-codepoint@1[
+      LiteralExpr [STRING] []
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.3.ast
new file mode 100644
index 0000000..28d357a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/string-to-codepoint2/string-to-codepoint2.3.ast
@@ -0,0 +1,11 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.string-to-codepoint@1[
+      LiteralExpr [STRING] [欢迎]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.3.ast
new file mode 100644
index 0000000..f1e9119
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen02/strlen02.3.ast
@@ -0,0 +1,27 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.string-length@1[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstu]
+    ]
+    FunctionCall null.string-length@1[
+      LiteralExpr [STRING] [ABCDEFGHIJKLMNOPQRSTU]
+    ]
+    FunctionCall null.string-length@1[
+      LiteralExpr [STRING] [abcdEFGHijklMNOPqrstu]
+    ]
+    FunctionCall null.string-length@1[
+      LiteralExpr [STRING] [abcd EFGH ijkl MNOP qrstu]
+    ]
+    FunctionCall null.string-length@1[
+      LiteralExpr [STRING] [   Hello World    !!!!....:-)]
+    ]
+    FunctionCall null.string-length@1[
+      LiteralExpr [STRING] [~!@#$%^&*()_+{}:?<>/.,';`][\]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.1.ast
new file mode 100644
index 0000000..0637761
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name : string
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.3.ast
new file mode 100644
index 0000000..0d292a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strlen03/strlen03.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.string-length@1[
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=name
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.3.ast
new file mode 100644
index 0000000..1792f53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt01/strtocpt01.3.ast
@@ -0,0 +1,4 @@
+Query:
+FunctionCall null.string-to-codepoint@1[
+  LiteralExpr [STRING] [ABCDEFGHIJKLMNOPQRSTUVWXYZ-01234567890]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.3.ast
new file mode 100644
index 0000000..b152b24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt02/strtocpt02.3.ast
@@ -0,0 +1,4 @@
+Query:
+FunctionCall null.string-to-codepoint@1[
+  LiteralExpr [STRING] ["'-=_+|\,./<>?:;~`]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.3.ast
new file mode 100644
index 0000000..ab3df0f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/strtocpt03/strtocpt03.3.ast
@@ -0,0 +1,4 @@
+Query:
+FunctionCall null.string-to-codepoint@1[
+  LiteralExpr [STRING] [!@#$%^&*()]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast
new file mode 100644
index 0000000..c2b1ad2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast
@@ -0,0 +1,70 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [str2]
+    :
+    FunctionCall null.substring@2[
+      LiteralExpr [STRING] [Hello World]
+      LiteralExpr [LONG] [10]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [str4]
+    :
+    FunctionCall null.substring@2[
+      LiteralExpr [STRING] [This is a test string]
+      LiteralExpr [LONG] [21]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [str6]
+    :
+    FunctionCall null.substring@2[
+      LiteralExpr [STRING] [This is a test string]
+      LiteralExpr [LONG] [22]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [str8]
+    :
+    FunctionCall null.substring@2[
+      LiteralExpr [STRING] [This is a test string]
+      LiteralExpr [LONG] [0]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [str10]
+    :
+    FunctionCall null.substring@2[
+      LiteralExpr [STRING] [This is a test string]
+      NEGATIVE LiteralExpr [LONG] [1]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [str13]
+    :
+    FunctionCall null.substring@2[
+      FunctionCall null.string-concat@1[
+        OrderedListConstructor [
+          LiteralExpr [STRING] [This is a test string]
+          LiteralExpr [STRING] [This is a another test string]
+        ]
+      ]
+      LiteralExpr [LONG] [21]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [str14]
+    :
+    FunctionCall null.substring@2[
+      LiteralExpr [STRING] [UC Irvine]
+      OperatorExpr [
+        FunctionCall null.string-length@1[
+          LiteralExpr [STRING] [UC Irvine]
+        ]
+        /
+        LiteralExpr [LONG] [2]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast
new file mode 100644
index 0000000..2d990a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast
@@ -0,0 +1,62 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [LONG] [7]
+      LiteralExpr [LONG] [5]
+    ]
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [11]
+    ]
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [hello world]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [9]
+    ]
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [ABCD]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [2]
+    ]
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [ABCD]
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [4]
+    ]
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [UC Irvine]
+      LiteralExpr [LONG] [4]
+      OperatorExpr [
+        FunctionCall null.string-length@1[
+          LiteralExpr [STRING] [UC Irvine]
+        ]
+        -
+        LiteralExpr [LONG] [3]
+      ]
+    ]
+    FunctionCall null.substring@3[
+      LiteralExpr [STRING] [UC Irvine]
+      LiteralExpr [LONG] [1]
+      FunctionCall null.string-length@1[
+        LiteralExpr [STRING] [UC Irvine]
+      ]
+    ]
+    FunctionCall null.substring@3[
+      FunctionCall null.substring@2[
+        LiteralExpr [STRING] [UC Irvine]
+        LiteralExpr [LONG] [4]
+      ]
+      LiteralExpr [LONG] [1]
+      FunctionCall null.string-length@1[
+        LiteralExpr [STRING] [Irvine]
+      ]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.1.ast
new file mode 100644
index 0000000..5a427aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast
new file mode 100644
index 0000000..8857ab6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast
@@ -0,0 +1,34 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.substring@3[
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=name
+  ]
+  LiteralExpr [LONG] [4]
+  OperatorExpr [
+    FunctionCall test.string-length@1[
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=name
+      ]
+    ]
+    -
+    LiteralExpr [LONG] [3]
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.1.ast
new file mode 100644
index 0000000..5a427aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name : string
+  }
+]
+DatasetDecl testdst(TestType) partitioned by [[name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast
new file mode 100644
index 0000000..0019ab6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.substring@2[
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=name
+  ]
+  LiteralExpr [LONG] [4]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testdst]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=a ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.3.ast
new file mode 100644
index 0000000..b149866
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-1/substring-after-1.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] [El]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.3.ast
new file mode 100644
index 0000000..af388f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-2/substring-after-2.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] [1]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.3.ast
new file mode 100644
index 0000000..f0a9069
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-3/substring-after-3.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] [HEllow]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.3.ast
new file mode 100644
index 0000000..7447595
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-after-4/substring-after-4.3.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    FunctionCall test.substring-after@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.3.ast
new file mode 100644
index 0000000..de9d58f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-1/substring-before-1.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] [ll]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.3.ast
new file mode 100644
index 0000000..76acb5b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-2/substring-before-2.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] [HEllow]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.3.ast
new file mode 100644
index 0000000..8025a14
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring-before-3/substring-before-3.3.ast
@@ -0,0 +1,44 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [STRING] []
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    FunctionCall test.substring-before@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast
new file mode 100644
index 0000000..ed84aaa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [LONG] [2]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.3.ast
new file mode 100644
index 0000000..fe4a308a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-2/substring2-2.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [LONG] [0]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast
new file mode 100644
index 0000000..865e373
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring@2[
+      LiteralExpr [STRING] [HEllow]
+      LiteralExpr [LONG] [10]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast
new file mode 100644
index 0000000..95d87e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-4/substring2-4.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.substring@2[
+      LiteralExpr [STRING] [HEllow]
+      NEGATIVE LiteralExpr [LONG] [1]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast
new file mode 100644
index 0000000..4443e58
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.substring@3[
+  Variable [ Name=x ]
+  LiteralExpr [LONG] [2]
+  LiteralExpr [LONG] [3]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [foobar]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.3.ast
new file mode 100644
index 0000000..a2e342b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase02/toLowerCase02.3.ast
@@ -0,0 +1,48 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [a   b  c  d  e  f  g]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [abcdefghij KLMNOP qrstu VWXYZ]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [abcdefghijklmnopqrstuvwxyz]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [this is a test string]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [smaller string]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [ABCD]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [AbCdEfGhIjKlMnOpQrStUvWxYz]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [abcdefghijkABCDEFGHIJK]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [HIJKLMNOPQRhijklmnopqr]
+    ]
+    FunctionCall null.lowercase@1[
+      FunctionCall null.substring@2[
+        LiteralExpr [STRING] [ABCDEFghIJKLMnopQRSTuvwxYZ01234]
+        LiteralExpr [LONG] [0]
+      ]
+    ]
+    FunctionCall null.lowercase@1[
+      LiteralExpr [STRING] [A33B2CD1EF78GHijk123LMNopqrstUVW3x2y01035Z]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.1.ast
new file mode 100644
index 0000000..0637761
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl TestType [
+  open RecordType {
+    name : string
+  }
+]
+DatasetDecl testds(TestType) partitioned by [[name]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.3.ast
new file mode 100644
index 0000000..8c8e6cc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase03/toLowerCase03.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.lowercase@1[
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=name
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.3.ast
new file mode 100644
index 0000000..3876d22
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/toLowerCase04/toLowerCase04.3.ast
@@ -0,0 +1,49 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    FunctionCall null.lowercase@1[
+      FunctionCall null.codepoint-to-string@1[
+        OrderedListConstructor [
+          LiteralExpr [LONG] [65]
+          LiteralExpr [LONG] [66]
+          LiteralExpr [LONG] [67]
+          LiteralExpr [LONG] [68]
+          LiteralExpr [LONG] [69]
+          LiteralExpr [LONG] [70]
+          LiteralExpr [LONG] [71]
+          LiteralExpr [LONG] [72]
+          LiteralExpr [LONG] [73]
+          LiteralExpr [LONG] [74]
+          LiteralExpr [LONG] [75]
+          LiteralExpr [LONG] [76]
+          LiteralExpr [LONG] [77]
+          LiteralExpr [LONG] [78]
+          LiteralExpr [LONG] [79]
+          LiteralExpr [LONG] [80]
+          LiteralExpr [LONG] [81]
+          LiteralExpr [LONG] [82]
+          LiteralExpr [LONG] [83]
+          LiteralExpr [LONG] [84]
+          LiteralExpr [LONG] [85]
+          LiteralExpr [LONG] [86]
+          LiteralExpr [LONG] [87]
+          LiteralExpr [LONG] [88]
+          LiteralExpr [LONG] [89]
+          LiteralExpr [LONG] [90]
+        ]
+      ]
+    ]
+    FunctionCall null.lowercase@1[
+      FunctionCall null.string-concat@1[
+        OrderedListConstructor [
+          LiteralExpr [STRING] [ABCDEFGHIJKLMNOP]
+          LiteralExpr [STRING] [QRSTUVWXYZ]
+        ]
+      ]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.3.ast
new file mode 100644
index 0000000..a9c5578
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/uppercase/uppercase.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    FunctionCall test.uppercase@1[
+      LiteralExpr [STRING] [Hellow]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    FunctionCall test.uppercase@1[
+      LiteralExpr [STRING] []
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    FunctionCall test.uppercase@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.3.ast
new file mode 100644
index 0000000..fde6704
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/01/01.3.ast
@@ -0,0 +1,16 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall test.subset-collection@3[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+    ]
+    LiteralExpr [LONG] [0]
+    LiteralExpr [LONG] [1]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.3.ast
new file mode 100644
index 0000000..ec75921
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/02/02.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall test.subset-collection@3[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.3.ast
new file mode 100644
index 0000000..81f5370
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/03/03.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall test.subset-collection@3[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [0]
+    LiteralExpr [LONG] [0]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.3.ast
new file mode 100644
index 0000000..b3f256c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/05/05.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall test.subset-collection@3[
+    OrderedListConstructor [
+      LiteralExpr [STRING] [a]
+      LiteralExpr [STRING] [b]
+      LiteralExpr [STRING] [c]
+      LiteralExpr [STRING] [d]
+    ]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.3.ast
new file mode 100644
index 0000000..9854a53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/06/06.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall test.subset-collection@3[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [2]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.3.ast
new file mode 100644
index 0000000..b390374
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/subset-collection/07/07.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall test.subset-collection@3[
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [10]
+  ]
+  AS
+  Variable [ Name=l ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast
new file mode 100644
index 0000000..185b162
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset-with-index/delete-from-loaded-dataset-with-index.5.ast
@@ -0,0 +1,32 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=c ]
+      Field=l_suppkey
+    ]
+    <
+    LiteralExpr [LONG] [150]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ast
new file mode 100644
index 0000000..02109d8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.3.ast
new file mode 100644
index 0000000..55c7a87
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/delete-from-loaded-dataset/delete-from-loaded-dataset.3.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ast
new file mode 100644
index 0000000..2e844ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl Name [
+  open RecordType {
+    first : string,
+    last : string
+  }
+]
+TypeDecl Person [
+  open RecordType {
+    name : Name
+  }
+]
+TypeDecl TestType [
+  open RecordType {
+    id : int32,
+    name : string,
+    locn : point,
+    zip : string,
+    person : Person
+  }
+]
+DatasetDecl t1(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.ast
new file mode 100644
index 0000000..81558b9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-empty-secondary-indexes/drop-empty-secondary-indexes.3.ast
@@ -0,0 +1,30 @@
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Index]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=IsPrimary
+      ]
+      =
+      LiteralExpr [FALSE]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=DataverseName
+      ]
+      =
+      LiteralExpr [STRING] [test]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.1.ast
new file mode 100644
index 0000000..bbc2751
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    unique1 : int64,
+    unique2 : int64,
+    two : int64,
+    four : int64,
+    ten : int64,
+    twenty : int64,
+    onePercent : int64,
+    tenPercent : int64,
+    twentyPercent : int64,
+    fiftyPercent : int64,
+    unique3 : int64,
+    evenOnePercent : int64,
+    oddOnePercent : int64,
+    stringu1 : string,
+    stringu2 : string,
+    string4 : string
+  }
+]
+DatasetDecl t1(Schema) partitioned by [[unique2]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.4.ast
new file mode 100644
index 0000000..de91ce6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/drop-index/drop-index.4.ast
@@ -0,0 +1,31 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [t1]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=unique1
+      ]
+      >
+      LiteralExpr [LONG] [10]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=stringu1
+      ]
+      =
+      LiteralExpr [STRING] [DGAAAAXXXXXXXXXXXXXXXXXXX]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.1.ast
new file mode 100644
index 0000000..9f0be39
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.3.ast
new file mode 100644
index 0000000..125e278
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/empty-load-with-index/empty-load-with-index.3.ast
@@ -0,0 +1,25 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_orderkey
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=l_linenumber
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [1]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ast
new file mode 100644
index 0000000..d6a98f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.1.ast
@@ -0,0 +1,10 @@
+TypeDecl Emp [
+  closed RecordType {
+    id : int64,
+    fname : string,
+    lname : string,
+    age : int64,
+    dept : string
+  }
+]
+DatasetDecl employee(Emp) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.ast
new file mode 100644
index 0000000..d3cf8a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset-with-index/insert-and-scan-dataset-with-index.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [test.employee]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.1.ast
new file mode 100644
index 0000000..537173f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.1.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+TypeDecl myDataType [
+  open RecordType {
+    id : int64
+  }
+]
+DatasetDecl myData(myDataType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.3.ast
new file mode 100644
index 0000000..c200c21
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/insert-and-scan-dataset/insert-and-scan-dataset.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=c ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [myData]
+  ]
+  AS
+  Variable [ Name=c ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast
new file mode 100644
index 0000000..3535ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
new file mode 100644
index 0000000..40474c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
@@ -0,0 +1,218 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [sum_qty]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_base_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_charge]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            +
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_tax
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_qty]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_price]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_disc]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast
new file mode 100644
index 0000000..a706d77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.1.ast
@@ -0,0 +1,15 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast
new file mode 100644
index 0000000..613b78d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-delete-rtree-secondary-index/scan-delete-rtree-secondary-index.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.1.ast
new file mode 100644
index 0000000..647b510
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    id : int64,
+    point : point
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.5.ast
new file mode 100644
index 0000000..1b0eba1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-persistent-to-temp/scan-insert-persistent-to-temp.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast
new file mode 100644
index 0000000..647b510
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    id : int64,
+    point : point
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast
new file mode 100644
index 0000000..1b0eba1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-rtree-secondary-index/scan-insert-rtree-secondary-index.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.1.ast
new file mode 100644
index 0000000..647b510
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.1.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+TypeDecl MyRecord [
+  closed RecordType {
+    id : int64,
+    point : point,
+    kwds : string,
+    line1 : line,
+    line2 : line,
+    poly1 : polygon,
+    poly2 : polygon,
+    rec : rectangle,
+    circle : circle
+  }
+]
+TypeDecl MyMiniRecord [
+  closed RecordType {
+    id : int64,
+    point : point
+  }
+]
+DatasetDecl MyData(MyRecord) partitioned by [[id]]
+DatasetDecl MyMiniData(MyMiniRecord) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.3.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.3.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.4.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.4.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.5.ast
new file mode 100644
index 0000000..1b0eba1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temp-dataset/scan-insert-temp-to-persistent/scan-insert-temp-to-persistent.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=id
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [MyMiniData]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  FunctionCall test.spatial-intersect@2[
+    FieldAccessor [
+      Variable [ Name=o ]
+      Field=point
+    ]
+    FunctionCall test.create-polygon@1[
+      OrderedListConstructor [
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [1.0]
+        LiteralExpr [DOUBLE] [0.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [4.0]
+        LiteralExpr [DOUBLE] [12.0]
+        LiteralExpr [DOUBLE] [1.0]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.3.ast
new file mode 100644
index 0000000..05dcf98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors/accessors.3.ast
@@ -0,0 +1,431 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [year1]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year2]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year3]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1987-11-19]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year4]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [09280329]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year5]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year6]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.string@1[
+        LiteralExpr [STRING] [-0003-01-09T23:12:12.39-07:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year7]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year8]
+    :
+    FunctionCall test.get-year@1[
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P8Y12M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [year-null]
+    :
+    FunctionCall test.get-year@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month1]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month2]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month3]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1987-11-19]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month4]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [09280329]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month5]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month6]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month7]
+    :
+    FunctionCall test.get-month@1[
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P8Y12M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [month-null]
+    :
+    FunctionCall test.get-month@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day1]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day2]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day3]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1987-11-19]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day4]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [09280329]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day5]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day6]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day7]
+    :
+    FunctionCall test.get-day@1[
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [P32DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [day-null]
+    :
+    FunctionCall test.get-day@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [hour1]
+    :
+    FunctionCall test.get-hour@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [hour2]
+    :
+    FunctionCall test.get-hour@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [hour3]
+    :
+    FunctionCall test.get-hour@1[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [12:23:34.930+07:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [hour4]
+    :
+    FunctionCall test.get-hour@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [hour5]
+    :
+    FunctionCall test.get-hour@1[
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [P32DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [hour-null]
+    :
+    FunctionCall test.get-hour@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min1]
+    :
+    FunctionCall test.get-minute@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min2]
+    :
+    FunctionCall test.get-minute@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min3]
+    :
+    FunctionCall test.get-minute@1[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [12:23:34.930+07:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min4]
+    :
+    FunctionCall test.get-minute@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min5]
+    :
+    FunctionCall test.get-minute@1[
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [P32DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [min-null]
+    :
+    FunctionCall test.get-minute@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [second1]
+    :
+    FunctionCall test.get-second@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [second2]
+    :
+    FunctionCall test.get-second@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [second3]
+    :
+    FunctionCall test.get-second@1[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [12:23:34.930+07:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [second4]
+    :
+    FunctionCall test.get-second@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [second5]
+    :
+    FunctionCall test.get-second@1[
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [P32DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [second-null]
+    :
+    FunctionCall test.get-second@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ms1]
+    :
+    FunctionCall test.get-millisecond@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ms2]
+    :
+    FunctionCall test.get-millisecond@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [19371229T20030628]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ms3]
+    :
+    FunctionCall test.get-millisecond@1[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [12:23:34.930+07:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ms4]
+    :
+    FunctionCall test.get-millisecond@1[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P3Y73M632DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ms5]
+    :
+    FunctionCall test.get-millisecond@1[
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [P32DT49H743M3948.94S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ms-null]
+    :
+    FunctionCall test.get-millisecond@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.3.ast
new file mode 100644
index 0000000..da3708c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval/accessors_interval.3.ast
@@ -0,0 +1,86 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [start1]
+    :
+    FunctionCall test.get-interval-start@1[
+      FunctionCall test.interval-from-date@2[
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [2010-10-30]
+        ]
+        LiteralExpr [STRING] [2013-04-01]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [end1]
+    :
+    FunctionCall test.get-interval-end@1[
+      FunctionCall test.interval-from-date@2[
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [2010-10-30]
+        ]
+        LiteralExpr [STRING] [2013-04-01]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [start2]
+    :
+    FunctionCall test.get-interval-start@1[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [08:09:10.234Z]
+        FunctionCall test.time@1[
+          LiteralExpr [STRING] [203040567+0800]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [end2]
+    :
+    FunctionCall test.get-interval-end@1[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [08:09:10.234Z]
+        FunctionCall test.time@1[
+          LiteralExpr [STRING] [203040567+0800]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [start3]
+    :
+    FunctionCall test.get-interval-start@1[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2009-09-01T00:00:00.000+08:00]
+        FunctionCall test.datetime-from-date-time@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [2013-04-04]
+          ]
+          FunctionCall test.time@1[
+            LiteralExpr [STRING] [00:00:00.000+08:00]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [end3]
+    :
+    FunctionCall test.get-interval-end@1[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2009-09-01T00:00:00.000+08:00]
+        FunctionCall test.datetime-from-date-time@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [2013-04-04]
+          ]
+          FunctionCall test.time@1[
+            LiteralExpr [STRING] [00:00:00.000+08:00]
+          ]
+        ]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.3.ast
new file mode 100644
index 0000000..133a0f7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/accessors_interval_null/accessors_interval_null.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [start-null-interval]
+    :
+    FunctionCall test.get-interval-start@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [end-null-interval]
+    :
+    FunctionCall test.get-interval-end@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.3.ast
new file mode 100644
index 0000000..9906449
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/adjust_timezone/adjust_timezone.3.ast
@@ -0,0 +1,60 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [time]
+    :
+    FunctionCall test.adjust-time-for-timezone@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [20:15:10.327]
+      ]
+      LiteralExpr [STRING] [+0800]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime]
+    :
+    FunctionCall test.adjust-datetime-for-timezone@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2010-10-23T01:12:13.329Z]
+      ]
+      LiteralExpr [STRING] [-0615]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null1]
+    :
+    FunctionCall test.adjust-time-for-timezone@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [+0800]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null2]
+    :
+    FunctionCall test.adjust-time-for-timezone@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [20:15:10.327]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null3]
+    :
+    FunctionCall test.adjust-datetime-for-timezone@2[
+      LiteralExpr [NULL]
+      LiteralExpr [STRING] [-0800]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null4]
+    :
+    FunctionCall test.adjust-datetime-for-timezone@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2010-10-23T01:12:13.329Z]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.3.ast
new file mode 100644
index 0000000..a36868f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/calendar_duration/calendar_duration.3.ast
@@ -0,0 +1,381 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cduration1]
+    :
+    FunctionCall test.calendar-duration-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P7382DT39283M3921.329S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [P7382DT39283M3921.329S]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-datetime@2[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [P7382DT39283M3921.329S]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration2]
+    :
+    FunctionCall test.calendar-duration-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-PT63H398212M3219.328S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c2]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [-PT63H398212M3219.328S]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-datetime@2[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [-PT63H398212M3219.328S]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration3]
+    :
+    FunctionCall test.calendar-duration-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1Y90M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c3]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [P1Y90M]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-datetime@2[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [P1Y90M]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration4]
+    :
+    FunctionCall test.calendar-duration-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P3Y89M4089DT47382.983S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c4]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [-P3Y89M4089DT47382.983S]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-datetime@2[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [-P3Y89M4089DT47382.983S]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration5]
+    :
+    FunctionCall test.calendar-duration-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1328-10-23]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P7382DT39283M3921.329S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c5]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [P7382DT39283M3921.329S]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-date@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [-1328-10-23]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [P7382DT39283M3921.329S]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration6]
+    :
+    FunctionCall test.calendar-duration-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1328-10-23]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-PT63H398212M3219.328S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c6]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [-PT63H398212M3219.328S]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-date@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [-1328-10-23]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [-PT63H398212M3219.328S]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration7]
+    :
+    FunctionCall test.calendar-duration-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1328-10-23]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1Y90M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c7]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [P1Y90M]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-date@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [-1328-10-23]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [P1Y90M]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration8]
+    :
+    FunctionCall test.calendar-duration-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1328-10-23]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P3Y89M4089DT47382.983S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c8]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [-P3Y89M4089DT47382.983S]
+        ]
+      ]
+      =
+      OperatorExpr [
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [-1328-10-23]
+        ]
+        +
+        FunctionCall test.calendar-duration-from-date@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [-1328-10-23]
+          ]
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [-P3Y89M4089DT47382.983S]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration-null-1]
+    :
+    FunctionCall test.calendar-duration-from-datetime@2[
+      LiteralExpr [NULL]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P7382DT39283M3921.329S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration-null-2]
+    :
+    FunctionCall test.calendar-duration-from-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1987-11-19T23:49:23.938]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration-null-3]
+    :
+    FunctionCall test.calendar-duration-from-date@2[
+      LiteralExpr [NULL]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P7382DT39283M3921.329S]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [cduration-null-4]
+    :
+    FunctionCall test.calendar-duration-from-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1328-10-23]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast
new file mode 100644
index 0000000..e5dfd2f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast
@@ -0,0 +1,250 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [date1]
+    :
+    FunctionCall test.date-from-unix-time-in-days@1[
+      LiteralExpr [LONG] [15600]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date2]
+    :
+    FunctionCall test.get-date-from-datetime@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date3]
+    :
+    FunctionCall test.get-date-from-datetime@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-10-11T02:30:23+03:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date4]
+    :
+    OperatorExpr [
+      FunctionCall test.date-from-unix-time-in-days@1[
+        LiteralExpr [LONG] [15600]
+      ]
+      +
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P2Y1M90DT30H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date5]
+    :
+    OperatorExpr [
+      FunctionCall test.get-date-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+      +
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P300Y900MT360000M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration1]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.get-date-from-datetime@1[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+          ]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [P300Y900MT360000M]
+        ]
+      ]
+      -
+      FunctionCall test.get-date-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration2]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.date-from-unix-time-in-days@1[
+          LiteralExpr [LONG] [15600]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [-P2Y1M90DT30H]
+        ]
+      ]
+      -
+      FunctionCall test.date-from-unix-time-in-days@1[
+        LiteralExpr [LONG] [15600]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    OperatorExpr [
+      FunctionCall test.date-from-unix-time-in-days@1[
+        LiteralExpr [LONG] [15600]
+      ]
+      =
+      OperatorExpr [
+        OperatorExpr [
+          FunctionCall test.date-from-unix-time-in-days@1[
+            LiteralExpr [LONG] [15600]
+          ]
+          +
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [-P2Y1M90DT30H]
+          ]
+        ]
+        +
+        OperatorExpr [
+          FunctionCall test.date-from-unix-time-in-days@1[
+            LiteralExpr [LONG] [15600]
+          ]
+          -
+          OperatorExpr [
+            FunctionCall test.date-from-unix-time-in-days@1[
+              LiteralExpr [LONG] [15600]
+            ]
+            +
+            FunctionCall test.duration@1[
+              LiteralExpr [STRING] [-P2Y1M90DT30H]
+            ]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c2]
+    :
+    OperatorExpr [
+      FunctionCall test.get-date-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+      =
+      OperatorExpr [
+        OperatorExpr [
+          FunctionCall test.get-date-from-datetime@1[
+            FunctionCall test.datetime@1[
+              LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+            ]
+          ]
+          +
+          FunctionCall test.duration@1[
+            LiteralExpr [STRING] [P300Y900MT360000M]
+          ]
+        ]
+        +
+        OperatorExpr [
+          FunctionCall test.get-date-from-datetime@1[
+            FunctionCall test.datetime@1[
+              LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+            ]
+          ]
+          -
+          OperatorExpr [
+            FunctionCall test.get-date-from-datetime@1[
+              FunctionCall test.datetime@1[
+                LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+              ]
+            ]
+            +
+            FunctionCall test.duration@1[
+              LiteralExpr [STRING] [P300Y900MT360000M]
+            ]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null1]
+    :
+    FunctionCall test.date-from-unix-time-in-days@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null2]
+    :
+    FunctionCall test.get-date-from-datetime@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null3]
+    :
+    OperatorExpr [
+      LiteralExpr [NULL]
+      +
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P2Y1M90DT30H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null4]
+    :
+    OperatorExpr [
+      FunctionCall test.date-from-unix-time-in-days@1[
+        LiteralExpr [LONG] [15600]
+      ]
+      +
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null5]
+    :
+    OperatorExpr [
+      LiteralExpr [NULL]
+      -
+      FunctionCall test.get-date-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null6]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.get-date-from-datetime@1[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+          ]
+        ]
+        +
+        FunctionCall test.duration@1[
+          LiteralExpr [STRING] [P300Y900MT360000M]
+        ]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast
new file mode 100644
index 0000000..ca6836e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast
@@ -0,0 +1,226 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [datetime1]
+    :
+    FunctionCall test.datetime-from-unix-time-in-ms@1[
+      LiteralExpr [LONG] [956007429]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime1secs]
+    :
+    FunctionCall test.datetime-from-unix-time-in-secs@1[
+      LiteralExpr [LONG] [1356048000]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime2]
+    :
+    FunctionCall test.datetime-from-date-time@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [1327-12-02]
+      ]
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [15:35:49.938-0800]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime3]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [956007429]
+      ]
+      +
+      OperatorExpr [
+        FunctionCall test.datetime-from-date-time@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [1327-12-02]
+          ]
+          FunctionCall test.time@1[
+            LiteralExpr [STRING] [15:35:49.938-0800]
+          ]
+        ]
+        -
+        FunctionCall test.datetime-from-unix-time-in-ms@1[
+          LiteralExpr [LONG] [956007429]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration1]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime-from-date-time@2[
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [1327-12-02]
+        ]
+        FunctionCall test.time@1[
+          LiteralExpr [STRING] [15:35:49.938-0800]
+        ]
+      ]
+      -
+      FunctionCall test.datetime-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [956007429]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [956007429]
+      ]
+      =
+      OperatorExpr [
+        OperatorExpr [
+          FunctionCall test.datetime-from-unix-time-in-ms@1[
+            LiteralExpr [LONG] [956007429]
+          ]
+          -
+          OperatorExpr [
+            FunctionCall test.datetime-from-unix-time-in-ms@1[
+              LiteralExpr [LONG] [956007429]
+            ]
+            +
+            OperatorExpr [
+              FunctionCall test.datetime-from-date-time@2[
+                FunctionCall test.date@1[
+                  LiteralExpr [STRING] [1327-12-02]
+                ]
+                FunctionCall test.time@1[
+                  LiteralExpr [STRING] [15:35:49.938-0800]
+                ]
+              ]
+              -
+              FunctionCall test.datetime-from-unix-time-in-ms@1[
+                LiteralExpr [LONG] [956007429]
+              ]
+            ]
+          ]
+        ]
+        +
+        OperatorExpr [
+          FunctionCall test.datetime-from-unix-time-in-ms@1[
+            LiteralExpr [LONG] [956007429]
+          ]
+          +
+          OperatorExpr [
+            FunctionCall test.datetime-from-date-time@2[
+              FunctionCall test.date@1[
+                LiteralExpr [STRING] [1327-12-02]
+              ]
+              FunctionCall test.time@1[
+                LiteralExpr [STRING] [15:35:49.938-0800]
+              ]
+            ]
+            -
+            FunctionCall test.datetime-from-unix-time-in-ms@1[
+              LiteralExpr [LONG] [956007429]
+            ]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null1]
+    :
+    FunctionCall test.datetime-from-unix-time-in-ms@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null1secs]
+    :
+    FunctionCall test.datetime-from-unix-time-in-secs@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null2]
+    :
+    FunctionCall test.datetime-from-date-time@2[
+      LiteralExpr [NULL]
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [15:35:49.938-0800]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null3]
+    :
+    FunctionCall test.datetime-from-date-time@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [1327-12-02]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null4]
+    :
+    OperatorExpr [
+      LiteralExpr [NULL]
+      -
+      FunctionCall test.datetime-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [956007429]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null5]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime-from-date-time@2[
+        FunctionCall test.date@1[
+          LiteralExpr [STRING] [1327-12-02]
+        ]
+        FunctionCall test.time@1[
+          LiteralExpr [STRING] [15:35:49.938-0800]
+        ]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null6]
+    :
+    OperatorExpr [
+      LiteralExpr [NULL]
+      +
+      OperatorExpr [
+        FunctionCall test.datetime-from-date-time@2[
+          FunctionCall test.date@1[
+            LiteralExpr [STRING] [1327-12-02]
+          ]
+          FunctionCall test.time@1[
+            LiteralExpr [STRING] [15:35:49.938-0800]
+          ]
+        ]
+        -
+        FunctionCall test.datetime-from-unix-time-in-ms@1[
+          LiteralExpr [LONG] [956007429]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null7]
+    :
+    OperatorExpr [
+      FunctionCall test.datetime-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [956007429]
+      ]
+      +
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.3.ast
new file mode 100644
index 0000000..f549357
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/day_of_week_01/day_of_week_01.3.ast
@@ -0,0 +1,56 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [1970-01-01]
+    :
+    FunctionCall test.day-of-week@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [1970-01-01]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [2013-08-06]
+    :
+    FunctionCall test.day-of-week@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2013-08-06]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [-2013-08-06]
+    :
+    FunctionCall test.day-of-week@1[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-2013-08-06]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [1913-08-06T15:53:28Z]
+    :
+    FunctionCall test.day-of-week@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1913-08-06T15:53:28Z]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [-1913-08-10T15:53:28Z]
+    :
+    FunctionCall test.day-of-week@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1913-08-10T15:53:28Z]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null]
+    :
+    FunctionCall test.day-of-week@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.3.ast
new file mode 100644
index 0000000..e6485e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_comps/duration_comps.3.ast
@@ -0,0 +1,113 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [yearMonthGreaterComp]
+    :
+    FunctionCall test.year-month-duration-greater-than@2[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P13M]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1Y]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dayTimeGreaterComp]
+    :
+    FunctionCall test.day-time-duration-greater-than@2[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1D]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P3D]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [yearMonthLessComp]
+    :
+    FunctionCall test.year-month-duration-less-than@2[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P13M]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1Y]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dayTimeLessComp]
+    :
+    FunctionCall test.day-time-duration-less-than@2[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1D]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P3D]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [equal1]
+    :
+    FunctionCall test.duration-equal@2[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1D]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [PT24H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [equal2]
+    :
+    FunctionCall test.duration-equal@2[
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P3D]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [PT24H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [equal3]
+    :
+    FunctionCall test.duration-equal@2[
+      FunctionCall test.duration-from-months@1[
+        FunctionCall test.months-from-year-month-duration@1[
+          FunctionCall test.get-year-month-duration@1[
+            FunctionCall test.duration@1[
+              LiteralExpr [STRING] [P1Y]
+            ]
+          ]
+        ]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [P1Y]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [equal4]
+    :
+    FunctionCall test.duration-equal@2[
+      FunctionCall test.duration-from-ms@1[
+        FunctionCall test.ms-from-day-time-duration@1[
+          FunctionCall test.get-day-time-duration@1[
+            FunctionCall test.duration@1[
+              LiteralExpr [STRING] [-P3D]
+            ]
+          ]
+        ]
+      ]
+      FunctionCall test.duration@1[
+        LiteralExpr [STRING] [-P3D]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.3.ast
new file mode 100644
index 0000000..0ab1988
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/duration_functions/duration_functions.3.ast
@@ -0,0 +1,41 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [dr1]
+    :
+    FunctionCall test.duration-from-interval@1[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dr2]
+    :
+    FunctionCall test.duration-from-interval@1[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2012-06-26T01:01:01.111]
+        LiteralExpr [STRING] [2012-07-27T02:02:02.222]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dr3]
+    :
+    FunctionCall test.duration-from-interval@1[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [12:32:38]
+        LiteralExpr [STRING] [20:29:20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dr4]
+    :
+    FunctionCall test.duration-from-interval@1[
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.3.ast
new file mode 100644
index 0000000..72400ac
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/get_overlapping_interval/get_overlapping_interval.3.ast
@@ -0,0 +1,137 @@
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [overlap1]
+    :
+    FunctionCall null.get-overlapping-interval@2[
+      FunctionCall null.interval-from-time@2[
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [11:23:39]
+        ]
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [18:27:19]
+        ]
+      ]
+      FunctionCall null.interval-from-time@2[
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [12:23:39]
+        ]
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [23:18:00]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap2]
+    :
+    FunctionCall null.get-overlapping-interval@2[
+      FunctionCall null.interval-from-time@2[
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [12:23:39]
+        ]
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [18:27:19]
+        ]
+      ]
+      FunctionCall null.interval-from-time@2[
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [07:19:39]
+        ]
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [09:18:00]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap3]
+    :
+    FunctionCall null.get-overlapping-interval@2[
+      FunctionCall null.interval-from-date@2[
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [1980-11-30]
+        ]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [1999-09-09]
+        ]
+      ]
+      FunctionCall null.interval-from-date@2[
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2014-01-01]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap4]
+    :
+    FunctionCall null.get-overlapping-interval@2[
+      FunctionCall null.interval-from-date@2[
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [1980-11-30]
+        ]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2099-09-09]
+        ]
+      ]
+      FunctionCall null.interval-from-date@2[
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-01-01]
+        ]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2014-01-01]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap5]
+    :
+    FunctionCall null.get-overlapping-interval@2[
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [1844-03-03T11:19:39]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-10-30T18:27:19]
+        ]
+      ]
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [1989-03-04T12:23:39]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2009-10-10T23:18:00]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap6]
+    :
+    FunctionCall null.get-overlapping-interval@2[
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [1989-03-04T12:23:39]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2000-10-30T18:27:19]
+        ]
+      ]
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [1844-03-03T11:19:39]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [1888-10-10T23:18:00]
+        ]
+      ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ast
new file mode 100644
index 0000000..d430f49
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.1.ast
@@ -0,0 +1,14 @@
+DataverseUse testdvt
+TypeDecl testtype [
+  open RecordType {
+    id : string,
+    dateField : date?,
+    timeField : time?,
+    datetimeField : datetime?,
+    durationField : duration?,
+    intervalField : interval?,
+    yearMonthDurationField : year-month-duration?,
+    dayTimeDurationField : day-time-duration?
+  }
+]
+DatasetDecl testds(testtype)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.3.ast
new file mode 100644
index 0000000..7f10756
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds/insert_from_ext_ds.3.ast
@@ -0,0 +1,68 @@
+DataverseUse testdvt
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [date]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=dateField
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=timeField
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=datetimeField
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=durationField
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=intervalField
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ymduration]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=yearMonthDurationField
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dtduration]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=dayTimeDurationField
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [testds]
+  ]
+  AS
+  Variable [ Name=r ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.ast
new file mode 100644
index 0000000..820b1d1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.ast
@@ -0,0 +1,15 @@
+DataverseUse timeTest
+TypeDecl timesType [
+  open RecordType {
+    date : date,
+    time : time,
+    datetime : datetime,
+    duration : duration,
+    year-month-duration : year-month-duration,
+    day-time-duration : day-time-duration,
+    date-interval : interval,
+    time-interval : interval,
+    datetime-interval : interval
+  }
+]
+DatasetDecl timeData(timesType) partitioned by [[date]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.2.ast
new file mode 100644
index 0000000..f4db438
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.2.ast
@@ -0,0 +1 @@
+DataverseUse timeTest
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.3.ast
new file mode 100644
index 0000000..dfa294f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.3.ast
@@ -0,0 +1,18 @@
+DataverseUse timeTest
+Query:
+SELECT ELEMENT [
+Variable [ Name=r ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [timeData]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=date
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.3.ast
new file mode 100644
index 0000000..90be652
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin/interval_bin.3.ast
@@ -0,0 +1,118 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [bin1]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [1990-01-01]
+      ]
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P1Y]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin2]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-1990-01-01]
+      ]
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P1Y]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin3]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1987-11-19T23:49:23.938]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1990-01-01T00:00:00.000Z]
+      ]
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P6M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin4]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1987-11-19T23:49:23.938]
+      ]
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [-1990-01-01T00:00:00.000Z]
+      ]
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [PT12H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin5]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [12:23:34.930+07:00]
+      ]
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [12:00:00]
+      ]
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [PT2H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin6]
+    :
+    FunctionCall test.interval-bin@3[
+      LiteralExpr [NULL]
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-0023-01-01]
+      ]
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P6M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin7]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+      LiteralExpr [NULL]
+      FunctionCall test.year-month-duration@1[
+        LiteralExpr [STRING] [P6M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [bin8]
+    :
+    FunctionCall test.interval-bin@3[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [2010-10-30]
+      ]
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-0023-01-01]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ast
new file mode 100644
index 0000000..22afd52
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int64,
+    timestamp : datetime
+  }
+]
+DatasetDecl tsdata(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.3.ast
new file mode 100644
index 0000000..c511a53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_0/interval_bin_gby_0.3.ast
@@ -0,0 +1,48 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tbin]
+    :
+    Variable [ Name=d ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      Variable [ Name=i ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tsdata]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Groupby
+  Variable [ Name=d ]
+  :=
+  FunctionCall test.interval-bin@3[
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=timestamp
+    ]
+    FunctionCall test.datetime@1[
+      LiteralExpr [STRING] [1990-01-01T00:00:00.000Z]
+    ]
+    FunctionCall test.year-month-duration@1[
+      LiteralExpr [STRING] [P20Y]
+    ]
+  ]
+  With
+  Variable [ Name=i ]
+
+Orderby
+  FunctionCall test.get-interval-start@1[
+    Variable [ Name=d ]
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ast
new file mode 100644
index 0000000..22afd52
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int64,
+    timestamp : datetime
+  }
+]
+DatasetDecl tsdata(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.3.ast
new file mode 100644
index 0000000..4f3fd53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_bin_gby_1/interval_bin_gby_1.3.ast
@@ -0,0 +1,50 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tbin]
+    :
+    Variable [ Name=d ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      Variable [ Name=i ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [tsdata]
+  ]
+  AS
+  Variable [ Name=i ]
+]
+Groupby
+  Variable [ Name=d ]
+  :=
+  FunctionCall test.interval-bin@3[
+    FunctionCall test.get-time-from-datetime@1[
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=timestamp
+      ]
+    ]
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [00:00:00.000Z]
+    ]
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [PT10M]
+    ]
+  ]
+  With
+  Variable [ Name=i ]
+
+Orderby
+  FunctionCall test.get-interval-start@1[
+    Variable [ Name=d ]
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.3.ast
new file mode 100644
index 0000000..338c5fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/interval_functions/interval_functions.3.ast
@@ -0,0 +1,398 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [before1]
+    :
+    FunctionCall test.interval-before@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2011-10-30]
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [before2]
+    :
+    FunctionCall test.interval-before@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-12-21]
+        LiteralExpr [STRING] [2013-01-01]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [after1]
+    :
+    FunctionCall test.interval-after@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2011-10-30]
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [after2]
+    :
+    FunctionCall test.interval-after@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-12-21]
+        LiteralExpr [STRING] [2013-01-01]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [meet1]
+    :
+    FunctionCall test.interval-meets@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2012-06-26T01:01:01.111]
+        LiteralExpr [STRING] [2012-07-27T02:02:02.222]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [20120727T020202222]
+        LiteralExpr [STRING] [2013-08-08T03:03:03.333]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [meet2]
+    :
+    FunctionCall test.interval-meets@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19000707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2012-06-26T01:01:01.111]
+        LiteralExpr [STRING] [2012-07-27T02:02:02.222]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [metby1]
+    :
+    FunctionCall test.interval-met-by@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [20120727T020202222]
+        LiteralExpr [STRING] [2013-08-08T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2012-06-26T01:01:01.111]
+        LiteralExpr [STRING] [2012-07-27T02:02:02.222]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [metby2]
+    :
+    FunctionCall test.interval-met-by@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19000707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [2012-06-26T01:01:01.111]
+        LiteralExpr [STRING] [2012-07-27T02:02:02.222]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlaps1]
+    :
+    FunctionCall test.interval-overlaps@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [12:32:38]
+        LiteralExpr [STRING] [20:29:20]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlaps2]
+    :
+    FunctionCall test.interval-overlaps@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [01:32:49]
+        LiteralExpr [STRING] [17:48:19]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlapped1]
+    :
+    FunctionCall test.interval-overlapped-by@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [12:32:38]
+        LiteralExpr [STRING] [20:29:20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlapped2]
+    :
+    FunctionCall test.interval-overlapped-by@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [01:32:49]
+        LiteralExpr [STRING] [17:48:19]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap1]
+    :
+    FunctionCall test.interval-overlapping@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [01:32:49]
+        LiteralExpr [STRING] [17:48:19]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [12:32:38]
+        LiteralExpr [STRING] [20:29:20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [overlap2]
+    :
+    FunctionCall test.interval-overlapping@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [01:32:49]
+        LiteralExpr [STRING] [17:48:19]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [starts1]
+    :
+    FunctionCall test.interval-starts@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [starts2]
+    :
+    FunctionCall test.interval-starts@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2011-10-30]
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [startedby1]
+    :
+    FunctionCall test.interval-started-by@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-12-21]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [startedby2]
+    :
+    FunctionCall test.interval-started-by@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2011-10-30]
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [covers1]
+    :
+    FunctionCall test.interval-covers@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [covers2]
+    :
+    FunctionCall test.interval-covers@2[
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [-19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [coveredby1]
+    :
+    FunctionCall test.interval-covered-by@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [coveredby2]
+    :
+    FunctionCall test.interval-covered-by@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [-19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2010-10-30]
+        LiteralExpr [STRING] [2010-11-30]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ends1]
+    :
+    FunctionCall test.interval-ends@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [12:32:38]
+        LiteralExpr [STRING] [20:29:20]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ends2]
+    :
+    FunctionCall test.interval-ends@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [endedby1]
+    :
+    FunctionCall test.interval-ended-by@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [12:32:38]
+        LiteralExpr [STRING] [20:29:20]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [endedby2]
+    :
+    FunctionCall test.interval-ended-by@2[
+      FunctionCall test.interval-from-time@2[
+        LiteralExpr [STRING] [17:48:19]
+        LiteralExpr [STRING] [22:19:49]
+      ]
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null1]
+    :
+    FunctionCall test.interval-before@2[
+      LiteralExpr [NULL]
+      FunctionCall test.interval-from-date@2[
+        LiteralExpr [STRING] [2011-10-30]
+        LiteralExpr [STRING] [2012-10-21]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null2]
+    :
+    FunctionCall test.interval-covered-by@2[
+      FunctionCall test.interval-from-datetime@2[
+        LiteralExpr [STRING] [19990707T020202222]
+        LiteralExpr [STRING] [2013-08-07T03:03:03.333]
+      ]
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null3]
+    :
+    FunctionCall test.interval-overlapping@2[
+      LiteralExpr [NULL]
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.3.ast
new file mode 100644
index 0000000..6d2e508
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins/overlap_bins.3.ast
@@ -0,0 +1,63 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [timebins]
+    :
+    FunctionCall null.overlap-bins@3[
+      FunctionCall null.interval-from-time@2[
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [17:23:37]
+        ]
+        FunctionCall null.time@1[
+          LiteralExpr [STRING] [18:30:21]
+        ]
+      ]
+      FunctionCall null.time@1[
+        LiteralExpr [STRING] [00:00:00]
+      ]
+      FunctionCall null.day-time-duration@1[
+        LiteralExpr [STRING] [PT30M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datebins]
+    :
+    FunctionCall null.overlap-bins@3[
+      FunctionCall null.interval-from-date@2[
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [1984-03-17]
+        ]
+        FunctionCall null.date@1[
+          LiteralExpr [STRING] [2013-08-22]
+        ]
+      ]
+      FunctionCall null.date@1[
+        LiteralExpr [STRING] [1990-01-01]
+      ]
+      FunctionCall null.year-month-duration@1[
+        LiteralExpr [STRING] [P20Y]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetimebins]
+    :
+    FunctionCall null.overlap-bins@3[
+      FunctionCall null.interval-from-datetime@2[
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [1800-01-01T23:59:48.938]
+        ]
+        FunctionCall null.datetime@1[
+          LiteralExpr [STRING] [2015-07-26T13:28:30.218]
+        ]
+      ]
+      FunctionCall null.datetime@1[
+        LiteralExpr [STRING] [1900-01-01T00:00:00.000]
+      ]
+      FunctionCall null.year-month-duration@1[
+        LiteralExpr [STRING] [P100Y]
+      ]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ast
new file mode 100644
index 0000000..959aa2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int32,
+    time : time,
+    duration : day-time-duration
+  }
+]
+DatasetDecl tsdata(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.ast
new file mode 100644
index 0000000..f3945e1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.ast
@@ -0,0 +1,109 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tbin]
+    :
+    FieldAccessor [
+      Variable [ Name=gen0 ]
+      Field=bin
+    ]
+  )
+  (
+    LiteralExpr [STRING] [interval]
+    :
+    Variable [ Name=itv ]
+  )
+  (
+    LiteralExpr [STRING] [overlap]
+    :
+    FunctionCall test.get-overlapping-interval@2[
+      FieldAccessor [
+        Variable [ Name=gen0 ]
+        Field=bin
+      ]
+      Variable [ Name=itv ]
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [i]
+        :
+        Variable [ Name=i ]
+      )
+      (
+        LiteralExpr [STRING] [bin]
+        :
+        Variable [ Name=bin ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [tsdata]
+      ]
+      AS
+      Variable [ Name=i ]
+,
+      FunctionCall test.overlap-bins@3[
+        FunctionCall test.interval-start-from-time@2[
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=time
+          ]
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=duration
+          ]
+        ]
+        FunctionCall test.time@1[
+          LiteralExpr [STRING] [00:00:00]
+        ]
+        FunctionCall test.day-time-duration@1[
+          LiteralExpr [STRING] [PT1H30M]
+        ]
+      ]
+      AS
+      Variable [ Name=j ]
+    ]
+    Groupby
+      Variable [ Name=bin ]
+      :=
+      Variable [ Name=j ]
+      With
+      Variable [ Name=i ]
+      Variable [ Name=j ]
+
+    Orderby
+      FunctionCall test.get-interval-start@1[
+        Variable [ Name=bin ]
+      ]
+      ASC
+
+  )
+  AS
+  Variable [ Name=gen0 ]
+,
+  FieldAccessor [
+    Variable [ Name=gen0 ]
+    Field=i
+  ]
+  AS
+  Variable [ Name=x ]
+]
+LetVariable [ Name=itv ]
+  :=
+  FunctionCall test.interval-start-from-time@2[
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=time
+    ]
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=duration
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ast
new file mode 100644
index 0000000..959aa2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+TypeDecl Schema [
+  closed RecordType {
+    id : int32,
+    time : time,
+    duration : day-time-duration
+  }
+]
+DatasetDecl tsdata(Schema) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.ast
new file mode 100644
index 0000000..d9ab42e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.ast
@@ -0,0 +1,108 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [timebin]
+    :
+    Variable [ Name=bin ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall test.count@1[
+      Variable [ Name=i2 ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [total_ms]
+    :
+    FunctionCall test.sum@1[
+      (
+        SELECT ELEMENT [
+        FunctionCall test.ms-from-day-time-duration@1[
+          FunctionCall test.duration-from-interval@1[
+            FunctionCall test.get-overlapping-interval@2[
+              Variable [ Name=bin ]
+              FieldAccessor [
+                Variable [ Name=i3 ]
+                Field=interval
+              ]
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=i2 ]
+          AS
+          Variable [ Name=i3 ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [interval]
+        :
+        FunctionCall test.interval-start-from-time@2[
+          FieldAccessor [
+            Variable [ Name=i1 ]
+            Field=time
+          ]
+          FieldAccessor [
+            Variable [ Name=i1 ]
+            Field=duration
+          ]
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [tsdata]
+      ]
+      AS
+      Variable [ Name=i1 ]
+    ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=i1 ]
+        Field=time
+      ]
+      ASC
+
+  )
+  AS
+  Variable [ Name=i2 ]
+,
+  FunctionCall test.overlap-bins@3[
+    FieldAccessor [
+      Variable [ Name=i2 ]
+      Field=interval
+    ]
+    FunctionCall test.time@1[
+      LiteralExpr [STRING] [00:00:00]
+    ]
+    FunctionCall test.day-time-duration@1[
+      LiteralExpr [STRING] [PT1H30M]
+    ]
+  ]
+  AS
+  Variable [ Name=j ]
+]
+Groupby
+  Variable [ Name=bin ]
+  :=
+  Variable [ Name=j ]
+  With
+  Variable [ Name=i2 ]
+  Variable [ Name=j ]
+
+Orderby
+  FunctionCall test.get-interval-start@1[
+    Variable [ Name=bin ]
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ast
new file mode 100644
index 0000000..7252320
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ast
@@ -0,0 +1,10 @@
+DataverseUse multitask
+TypeDecl LogType [
+  closed RecordType {
+    row_id : int32,
+    time : time,
+    duration : int32,
+    app : string
+  }
+]
+DatasetDecl logs(LogType) partitioned by [[row_id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.ast
new file mode 100644
index 0000000..3a42221
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.ast
@@ -0,0 +1 @@
+DataverseUse multitask
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.ast
new file mode 100644
index 0000000..5197186
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.ast
@@ -0,0 +1,138 @@
+DataverseUse multitask
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [timebin]
+    :
+    Variable [ Name=bin ]
+  )
+  (
+    LiteralExpr [STRING] [subgroups]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [subgid]
+          :
+          Variable [ Name=subgid ]
+        )
+        (
+          LiteralExpr [STRING] [item_count]
+          :
+          FunctionCall multitask.count@1[
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [logs]
+        ]
+        AS
+        Variable [ Name=i ]
+      ]
+      Where
+        FunctionCall multitask.interval-covers@2[
+          Variable [ Name=bin ]
+          FunctionCall multitask.interval-start-from-time@2[
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=time
+            ]
+            FunctionCall multitask.duration-from-ms@1[
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=duration
+              ]
+            ]
+          ]
+        ]
+      Groupby
+        Variable [ Name=subgid ]
+        :=
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=app
+        ]
+        With
+        Variable [ Name=i ]
+        Variable [ Name=bin ]
+
+      Orderby
+        Variable [ Name=subgid ]
+        ASC
+        FunctionCall multitask.count@1[
+          Variable [ Name=i ]
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall multitask.overlap-bins@3[
+    FunctionCall multitask.interval-from-time@2[
+      FunctionCall multitask.min@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=time
+          ]
+          ]
+          FROM [            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [logs]
+            ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+      FunctionCall multitask.max@1[
+        (
+          SELECT ELEMENT [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=time
+            ]
+            +
+            FunctionCall multitask.duration-from-ms@1[
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=i ]
+                  Field=duration
+                ]
+                *
+                LiteralExpr [LONG] [1000]
+              ]
+            ]
+          ]
+          ]
+          FROM [            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [logs]
+            ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+    ]
+    FunctionCall multitask.time@1[
+      LiteralExpr [STRING] [00:00:00.000]
+    ]
+    FunctionCall multitask.day-time-duration@1[
+      LiteralExpr [STRING] [PT1M]
+    ]
+  ]
+  AS
+  Variable [ Name=bin ]
+]
+Orderby
+  FunctionCall multitask.get-interval-start@1[
+    Variable [ Name=bin ]
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.3.ast
new file mode 100644
index 0000000..8f307fa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_01/parse_01.3.ast
@@ -0,0 +1,158 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [date1]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [2013-8-23]
+      LiteralExpr [STRING] [YY-M-D]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date2]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [Aug 12 -12]
+      LiteralExpr [STRING] [MMM D Y]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date3]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [-1234-01-01]
+      LiteralExpr [STRING] [YYYY-MM-DD]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date4]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [09/11/-1980]
+      LiteralExpr [STRING] [D/M/Y]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date5]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [09/11/-1990]
+      LiteralExpr [STRING] [YY-M-D|MMM D Y|D/M/Y]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date6]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [Mon Aug 19 2013]
+      LiteralExpr [STRING] [W MMM D Y]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [data7]
+    :
+    FunctionCall test.parse-date@2[
+      LiteralExpr [STRING] [SKIPMEPLEASE Mon Aug SKIPME1ALSO 19 2013]
+      LiteralExpr [STRING] [O W MMM O D Y]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time1]
+    :
+    FunctionCall test.parse-time@2[
+      LiteralExpr [STRING] [8:23:49]
+      LiteralExpr [STRING] [h:m:s]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time2]
+    :
+    FunctionCall test.parse-time@2[
+      LiteralExpr [STRING] [8.19.23:32]
+      LiteralExpr [STRING] [h.m.s:nn]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time3]
+    :
+    FunctionCall test.parse-time@2[
+      LiteralExpr [STRING] [08.19.23:32 pm]
+      LiteralExpr [STRING] [h.m.s:nn a]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time4]
+    :
+    FunctionCall test.parse-time@2[
+      LiteralExpr [STRING] [6:30:40.948 pm PST]
+      LiteralExpr [STRING] [h:mm:ss.nnn a z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time5]
+    :
+    FunctionCall test.parse-time@2[
+      LiteralExpr [STRING] [6:30:40.948 pm PST]
+      LiteralExpr [STRING] [h:m:s|h.m.s:nn|h.m.s:nn a|h:mm:ss.nnn a z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime1]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [Dec 30 -1203 3:48:27 PM]
+      LiteralExpr [STRING] [MMM DD YYYY h:m:s a]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime2]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [12/30/-1203 03:48:27.392 PM Asia/Shanghai]
+      LiteralExpr [STRING] [MM/DD/YYY hh:mm:ss.nnn a z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime3]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [1723-12-03T23:59:23.392Z]
+      LiteralExpr [STRING] [YYYY-MM-DDThh:mm:ss.nnnz]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime4]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [1723-12-03T23:59:23.392-04:00]
+      LiteralExpr [STRING] [YYYY-MM-DDThh:mm:ss.nnnz]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime5]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [1723-12-03T23:59:23.392-04:00]
+      LiteralExpr [STRING] [MMM DD YYYY h:m:s a|MM/DD/YYY hh:mm:ss.nnn a z|YYYY-MM-DDThh:mm:ss.nnnz]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime6]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [1970-01-01 Thu 23:59:23.392-04:00]
+      LiteralExpr [STRING] [MMM DD YYYY h:m:s a|MM/DD/YYY hh:mm:ss.nnn a z|YYYY-MM-DD W hh:mm:ss.nnnz]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime7]
+    :
+    FunctionCall test.parse-datetime@2[
+      LiteralExpr [STRING] [1723-12-03 What3v3r STRINGHERE 23:59:23.392-04:00]
+      LiteralExpr [STRING] [MMM DD YYYY h:m:s a|MM/DD/YYY hh:mm:ss.nnn a z|YYYY-MM-DD O O hh:mm:ss.nnnz]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.3.ast
new file mode 100644
index 0000000..1fe2ac2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/parse_02/parse_02.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [date-string-1]
+    :
+    FunctionCall test.print-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-0123-01-30]
+      ]
+      LiteralExpr [STRING] [YY/M/D]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-string-2]
+    :
+    FunctionCall test.print-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-0123-01-30]
+      ]
+      LiteralExpr [STRING] [MMM DD, YYYY]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [date-string-3]
+    :
+    FunctionCall test.print-date@2[
+      FunctionCall test.date@1[
+        LiteralExpr [STRING] [-0123-01-30]
+      ]
+      LiteralExpr [STRING] [YYYY/MM/DD]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-string-1]
+    :
+    FunctionCall test.print-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [08:07:29.030Z]
+      ]
+      LiteralExpr [STRING] [h.m.s.nn a z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time-string-2]
+    :
+    FunctionCall test.print-time@2[
+      FunctionCall test.time@1[
+        LiteralExpr [STRING] [08:07:29.030Z]
+      ]
+      LiteralExpr [STRING] [hh.mm.ss.nnn a z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-string-1]
+    :
+    FunctionCall test.print-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [0137-12-31T23:59:59.999+08:00]
+      ]
+      LiteralExpr [STRING] [MMM DD h:m:s.nnn a YY z]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-string-2]
+    :
+    FunctionCall test.print-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [0137-12-31T23:59:59.999+08:00]
+      ]
+      LiteralExpr [STRING] [YYYY/MMM/DD h:m:s.nnnz a]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [datetime-string-3]
+    :
+    FunctionCall test.print-datetime@2[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [0137-12-31T23:59:59.999+08:00]
+      ]
+      LiteralExpr [STRING] [YYYY-MM-DDThh:mm:ss.nnnz]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast
new file mode 100644
index 0000000..3b8a3c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast
@@ -0,0 +1,246 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [time1]
+    :
+    FunctionCall test.time-from-unix-time-in-ms@1[
+      LiteralExpr [LONG] [1560074]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time2]
+    :
+    FunctionCall test.get-time-from-datetime@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time3]
+    :
+    FunctionCall test.get-time-from-datetime@1[
+      FunctionCall test.datetime@1[
+        LiteralExpr [STRING] [2012-10-11T02:30:23+03:00]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time4]
+    :
+    OperatorExpr [
+      FunctionCall test.time-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [1560074]
+      ]
+      +
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [-PT30H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [time5]
+    :
+    OperatorExpr [
+      FunctionCall test.get-time-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+      +
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [PT36M]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration1]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.get-time-from-datetime@1[
+          FunctionCall test.datetime@1[
+            LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+          ]
+        ]
+        +
+        FunctionCall test.day-time-duration@1[
+          LiteralExpr [STRING] [PT36M]
+        ]
+      ]
+      -
+      FunctionCall test.get-time-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [duration2]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.time-from-unix-time-in-ms@1[
+          LiteralExpr [LONG] [1560074]
+        ]
+        +
+        FunctionCall test.day-time-duration@1[
+          LiteralExpr [STRING] [-PT30H]
+        ]
+      ]
+      -
+      FunctionCall test.time-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [1560074]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c1]
+    :
+    OperatorExpr [
+      FunctionCall test.time-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [1560074]
+      ]
+      =
+      OperatorExpr [
+        OperatorExpr [
+          FunctionCall test.time-from-unix-time-in-ms@1[
+            LiteralExpr [LONG] [1560074]
+          ]
+          -
+          OperatorExpr [
+            FunctionCall test.time-from-unix-time-in-ms@1[
+              LiteralExpr [LONG] [1560074]
+            ]
+            +
+            FunctionCall test.day-time-duration@1[
+              LiteralExpr [STRING] [-PT30H]
+            ]
+          ]
+        ]
+        +
+        OperatorExpr [
+          FunctionCall test.time-from-unix-time-in-ms@1[
+            LiteralExpr [LONG] [1560074]
+          ]
+          +
+          FunctionCall test.day-time-duration@1[
+            LiteralExpr [STRING] [-PT30H]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [c2]
+    :
+    OperatorExpr [
+      FunctionCall test.get-time-from-datetime@1[
+        FunctionCall test.datetime@1[
+          LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+        ]
+      ]
+      =
+      OperatorExpr [
+        OperatorExpr [
+          FunctionCall test.get-time-from-datetime@1[
+            FunctionCall test.datetime@1[
+              LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+            ]
+          ]
+          +
+          FunctionCall test.day-time-duration@1[
+            LiteralExpr [STRING] [PT36M]
+          ]
+        ]
+        +
+        OperatorExpr [
+          FunctionCall test.get-time-from-datetime@1[
+            FunctionCall test.datetime@1[
+              LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+            ]
+          ]
+          -
+          OperatorExpr [
+            FunctionCall test.get-time-from-datetime@1[
+              FunctionCall test.datetime@1[
+                LiteralExpr [STRING] [1327-12-02T23:35:49.938Z]
+              ]
+            ]
+            +
+            FunctionCall test.day-time-duration@1[
+              LiteralExpr [STRING] [PT36M]
+            ]
+          ]
+        ]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null1]
+    :
+    FunctionCall test.time-from-unix-time-in-ms@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null2]
+    :
+    FunctionCall test.get-time-from-datetime@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null3]
+    :
+    OperatorExpr [
+      LiteralExpr [NULL]
+      +
+      FunctionCall test.day-time-duration@1[
+        LiteralExpr [STRING] [-PT30H]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null4]
+    :
+    OperatorExpr [
+      FunctionCall test.time-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [1560074]
+      ]
+      +
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null5]
+    :
+    OperatorExpr [
+      LiteralExpr [NULL]
+      -
+      FunctionCall test.time-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [1560074]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [null6]
+    :
+    OperatorExpr [
+      OperatorExpr [
+        FunctionCall test.time-from-unix-time-in-ms@1[
+          LiteralExpr [LONG] [1560074]
+        ]
+        +
+        FunctionCall test.day-time-duration@1[
+          LiteralExpr [STRING] [-PT30H]
+        ]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.1.ast
new file mode 100644
index 0000000..e0d0fd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.1.ast
@@ -0,0 +1,50 @@
+DataverseUse TinySocial
+TypeDecl TwitterUserType [
+  open RecordType {
+    screen-name : string,
+    lang : string,
+    friends_count : int64,
+    statuses_count : int64,
+    name : string,
+    followers_count : int64
+  }
+]
+TypeDecl TweetMessageType [
+  closed RecordType {
+    tweetid : string,
+    user : TwitterUserType,
+    sender-location : point?,
+    send-time : datetime,
+    referred-topics : UnorderedList <string>
+,
+    message-text : string
+  }
+]
+TypeDecl EmploymentType [
+  open RecordType {
+    organization-name : string,
+    start-date : date,
+    end-date : date?
+  }
+]
+TypeDecl FacebookUserType [
+  closed RecordType {
+    id : int64,
+    alias : string,
+    name : string,
+    user-since : datetime,
+    friend-ids : UnorderedList <int64>
+,
+    employment : OrderedList [EmploymentType]
+
+  }
+]
+TypeDecl FacebookMessageType [
+  closed RecordType {
+    message-id : int64,
+    author-id : int64,
+    in-response-to : int64?,
+    sender-location : point?,
+    message : string
+  }
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.10.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.10.ast
new file mode 100644
index 0000000..186b777
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.10.ast
@@ -0,0 +1,73 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=message-text
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nearby-messages]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [msgtxt]
+          :
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=message-text
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          FunctionCall TinySocial.spatial-distance@2[
+            FieldAccessor [
+              Variable [ Name=t ]
+              Field=sender-location
+            ]
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=sender-location
+            ]
+          ]
+          <=
+          LiteralExpr [LONG] [1]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=message-text
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=message-text
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.11.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.11.ast
new file mode 100644
index 0000000..ece5063
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.11.ast
@@ -0,0 +1,87 @@
+DataverseUse TinySocial
+Set simfunction=edit-distance
+Set simthreshold=3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [id]
+    :
+    FieldAccessor [
+      Variable [ Name=fbu ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=fbu ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [similar-users]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [twitter-screenname]
+          :
+          FieldAccessor [
+            Variable [ Name=tu ]
+            Field=screen-name
+          ]
+        )
+        (
+          LiteralExpr [STRING] [twitter-name]
+          :
+          FieldAccessor [
+            Variable [ Name=tu ]
+            Field=name
+          ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t ]
+      ]
+      LetVariable [ Name=tu ]
+        :=
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=user
+        ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=tu ]
+            Field=name
+          ]
+          ~=
+          FieldAccessor [
+            Variable [ Name=fbu ]
+            Field=name
+          ]
+        ]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=fbu ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=fbu ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast
new file mode 100644
index 0000000..2b942b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast
@@ -0,0 +1,36 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=fbu ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=fbu ]
+]
+Where
+  QuantifiedExpression SOME [
+    [Variable [ Name=e ]
+    In
+      FieldAccessor [
+        Variable [ Name=fbu ]
+        Field=employment
+      ]
+    ]
+    Satifies [
+      FunctionCall TinySocial.is-null@1[
+        FieldAccessor [
+          Variable [ Name=e ]
+          Field=end-date
+        ]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=fbu ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast
new file mode 100644
index 0000000..c78d170
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast
@@ -0,0 +1,38 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=fbu ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=fbu ]
+]
+Where
+  QuantifiedExpression EVERY [
+    [Variable [ Name=e ]
+    In
+      FieldAccessor [
+        Variable [ Name=fbu ]
+        Field=employment
+      ]
+    ]
+    Satifies [
+      FunctionCall TinySocial.not@1[
+        FunctionCall TinySocial.is-null@1[
+          FieldAccessor [
+            Variable [ Name=e ]
+            Field=end-date
+          ]
+        ]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=fbu ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.14.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.14.ast
new file mode 100644
index 0000000..443473e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.14.ast
@@ -0,0 +1,17 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=fbu ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookUsers]
+      ]
+      AS
+      Variable [ Name=fbu ]
+    ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.15.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.15.ast
new file mode 100644
index 0000000..d79d874
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.15.ast
@@ -0,0 +1,41 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user]
+    :
+    Variable [ Name=uid ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall TinySocial.count@1[
+      Variable [ Name=t ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  Variable [ Name=uid ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=user
+    ]
+    Field=screen-name
+  ]
+  With
+  Variable [ Name=t ]
+
+Orderby
+  Variable [ Name=uid ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.16.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.16.ast
new file mode 100644
index 0000000..d79d874
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.16.ast
@@ -0,0 +1,41 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user]
+    :
+    Variable [ Name=uid ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall TinySocial.count@1[
+      Variable [ Name=t ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  Variable [ Name=uid ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=user
+    ]
+    Field=screen-name
+  ]
+  With
+  Variable [ Name=t ]
+
+Orderby
+  Variable [ Name=uid ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.17.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.17.ast
new file mode 100644
index 0000000..3f22cd6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.17.ast
@@ -0,0 +1,48 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [user]
+    :
+    Variable [ Name=uid ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    Variable [ Name=c ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  Variable [ Name=uid ]
+  :=
+  FieldAccessor [
+    FieldAccessor [
+      Variable [ Name=t ]
+      Field=user
+    ]
+    Field=screen-name
+  ]
+  With
+  Variable [ Name=t ]
+
+LetVariable [ Name=c ]
+  :=
+  FunctionCall TinySocial.count@1[
+    Variable [ Name=t ]
+  ]
+Orderby
+  Variable [ Name=c ]
+  ASC
+  Variable [ Name=uid ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [3]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.18.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.18.ast
new file mode 100644
index 0000000..04c2dfa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.18.ast
@@ -0,0 +1,77 @@
+DataverseUse TinySocial
+Set simfunction=jaccard
+Set simthreshold=0.3
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [tweet]
+    :
+    Variable [ Name=t ]
+  )
+  (
+    LiteralExpr [STRING] [similar-tweets]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=referred-topics
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [TweetMessages]
+        ]
+        AS
+        Variable [ Name=t2 ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=referred-topics
+            ]
+            ~=
+            FieldAccessor [
+              Variable [ Name=t ]
+              Field=referred-topics
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=t2 ]
+              Field=tweetid
+            ]
+            !=
+            FieldAccessor [
+              Variable [ Name=t ]
+              Field=tweetid
+            ]
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=tweetid
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.19.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.19.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.19.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.2.ast
new file mode 100644
index 0000000..a6e2ec9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.2.ast
@@ -0,0 +1,5 @@
+DataverseUse TinySocial
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message-id]]
+DatasetDecl TwitterUsers(TwitterUserType) partitioned by [[screen-name]]
+DatasetDecl TweetMessages(TweetMessageType) partitioned by [[tweetid]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.20.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.20.ast
new file mode 100644
index 0000000..aab796b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.20.ast
@@ -0,0 +1,18 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=t ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TweetMessages]
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=tweetid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.21.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.21.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.21.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.22.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.22.ast
new file mode 100644
index 0000000..f106f19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.22.ast
@@ -0,0 +1,26 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.count@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=t ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [TweetMessages]
+      ]
+      AS
+      Variable [ Name=t ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=tweetid
+        ]
+        =
+        LiteralExpr [STRING] [13]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.3.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.3.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.4.ast
new file mode 100644
index 0000000..760a841
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.4.ast
@@ -0,0 +1,20 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+    =
+    LiteralExpr [LONG] [8]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.5.ast
new file mode 100644
index 0000000..2aa7368
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.5.ast
@@ -0,0 +1,38 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      >=
+      LiteralExpr [LONG] [2]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=id
+      ]
+      <=
+      LiteralExpr [LONG] [4]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.6.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.6.ast
new file mode 100644
index 0000000..ebb834b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.6.ast
@@ -0,0 +1,42 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+Variable [ Name=user ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=user-since
+      ]
+      >=
+      FunctionCall TinySocial.datetime@1[
+        LiteralExpr [STRING] [2010-07-22T00:00:00]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=user ]
+        Field=user-since
+      ]
+      <=
+      FunctionCall TinySocial.datetime@1[
+        LiteralExpr [STRING] [2012-07-29T23:59:59]
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.7.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.7.ast
new file mode 100644
index 0000000..fc54b9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.7.ast
@@ -0,0 +1,58 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=message
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=message ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=author-id
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=message ]
+    Field=message-id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.8.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.8.ast
new file mode 100644
index 0000000..fc54b9d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.8.ast
@@ -0,0 +1,58 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [message]
+    :
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=message
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookMessages]
+  ]
+  AS
+  Variable [ Name=message ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=message ]
+      Field=author-id
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=id
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=message ]
+    Field=message-id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.9.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.9.ast
new file mode 100644
index 0000000..4f5ba43
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.9.ast
@@ -0,0 +1,64 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [uname]
+    :
+    FieldAccessor [
+      Variable [ Name=user ]
+      Field=name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [messages]
+    :
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=message
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [FacebookMessages]
+        ]
+        AS
+        Variable [ Name=message ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=message ]
+            Field=author-id
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=user ]
+            Field=id
+          ]
+        ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=message ]
+          Field=message-id
+        ]
+        ASC
+
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [FacebookUsers]
+  ]
+  AS
+  Variable [ Name=user ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=user ]
+    Field=name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.ast
new file mode 100644
index 0000000..f3bb967
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_01/counthashed-gram-tokens_01.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Jürgen S. Generic's Car]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.counthashed-gram-tokens@3[
+    Variable [ Name=txt ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.ast
new file mode 100644
index 0000000..069f959
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-gram-tokens_02/counthashed-gram-tokens_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Jürgen S. Generic's Car]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.counthashed-gram-tokens@3[
+    Variable [ Name=txt ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [TRUE]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.ast
new file mode 100644
index 0000000..bca36f6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/counthashed-word-tokens_01/counthashed-word-tokens_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen.]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.counthashed-word-tokens@1[
+    Variable [ Name=txt ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.3.ast
new file mode 100644
index 0000000..28db2a4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_01/gram-tokens_01.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Jürgen S. Generic's Car]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    Variable [ Name=txt ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.3.ast
new file mode 100644
index 0000000..09febc7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/gram-tokens_02/gram-tokens_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Jürgen S. Generic's Car]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.gram-tokens@3[
+    Variable [ Name=txt ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [TRUE]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.ast
new file mode 100644
index 0000000..ff45c5b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_01/hashed-gram-tokens_01.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Jürgen S. Generic's Car]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.hashed-gram-tokens@3[
+    Variable [ Name=txt ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [FALSE]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.ast
new file mode 100644
index 0000000..89a551b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-gram-tokens_02/hashed-gram-tokens_02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Jürgen S. Generic's Car]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.hashed-gram-tokens@3[
+    Variable [ Name=txt ]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [TRUE]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.ast
new file mode 100644
index 0000000..d304f15
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/hashed-word-tokens_01/hashed-word-tokens_01.3.ast
@@ -0,0 +1,18 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen.]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.hashed-word-tokens@1[
+    Variable [ Name=txt ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.3.ast
new file mode 100644
index 0000000..778567b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_01/word-tokens_01.3.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [Hello World, I would like to inform you of the importance of Foo Bar. Yes, Foo Bar. Jürgen.]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    Variable [ Name=txt ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.3.ast
new file mode 100644
index 0000000..f9ee71a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tokenizers/word-tokens_02/word-tokens_02.3.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+Query:
+LetVariable [ Name=txt ]
+  :=
+  LiteralExpr [STRING] [ΩΣ]
+LetVariable [ Name=tokens ]
+  :=
+  FunctionCall test.word-tokens@1[
+    Variable [ Name=txt ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=token ]
+]
+FROM [  Variable [ Name=tokens ]
+  AS
+  Variable [ Name=token ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast
new file mode 100644
index 0000000..3535ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
new file mode 100644
index 0000000..40474c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
@@ -0,0 +1,218 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [sum_qty]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_base_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_charge]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            +
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_tax
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_qty]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_price]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_disc]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
new file mode 100644
index 0000000..52df01f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
@@ -0,0 +1,755 @@
+DataverseUse tpch
+FunctionDecl tmp1([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [s_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_partkey]
+        :
+        FieldAccessor [
+          Variable [ Name=p ]
+          Field=p_partkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [ps_supplycost]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=ps_supplycost
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_mfgr]
+        :
+        FieldAccessor [
+          Variable [ Name=p ]
+          Field=p_mfgr
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_address]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_phone]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_phone
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_comment]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_comment
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Part ]
+      AS
+      Variable [ Name=p ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_supplycost
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_address]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_comment
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=Partsupp ]
+          AS
+          Variable [ Name=ps ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_acctbal]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_acctbal
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_address]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_address
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_phone]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_phone
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_comment]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_comment
+                ]
+              )
+            ]
+            ]
+            FROM [              Variable [ Name=Supplier ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  Variable [ Name=Region ]
+                  AS
+                  Variable [ Name=r ]
+,
+                  Variable [ Name=Nation ]
+                  AS
+                  Variable [ Name=n ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=n ]
+                        Field=n_regionkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_regionkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_name
+                      ]
+                      =
+                      LiteralExpr [STRING] [EUROPE]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=rn ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=srn ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=pssrn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=pssrn ]
+            Field=p_partkey
+          ]
+        ]
+        and
+        FunctionCall tpch.like@2[
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_type
+          ]
+          LiteralExpr [STRING] [%BRASS]
+        ]
+      ]
+  )
+}
+
+FunctionDecl tmp2([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [p_partkey]
+        :
+        Variable [ Name=p_partkey ]
+      )
+      (
+        LiteralExpr [STRING] [ps_min_supplycost]
+        :
+        FunctionCall tpch.min@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=ps_supplycost
+            ]
+            ]
+            FROM [              Variable [ Name=pssrn ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Part ]
+      AS
+      Variable [ Name=p ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_supplycost
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_address]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_comment
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=Partsupp ]
+          AS
+          Variable [ Name=ps ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_acctbal]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_acctbal
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_address]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_address
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_phone]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_phone
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_comment]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_comment
+                ]
+              )
+            ]
+            ]
+            FROM [              Variable [ Name=Supplier ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  Variable [ Name=Region ]
+                  AS
+                  Variable [ Name=r ]
+,
+                  Variable [ Name=Nation ]
+                  AS
+                  Variable [ Name=n ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=n ]
+                        Field=n_regionkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_regionkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_name
+                      ]
+                      =
+                      LiteralExpr [STRING] [EUROPE]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=rn ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=srn ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=pssrn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=pssrn ]
+            Field=p_partkey
+          ]
+        ]
+        and
+        FunctionCall tpch.like@2[
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_type
+          ]
+          LiteralExpr [STRING] [%BRASS]
+        ]
+      ]
+    Groupby
+      Variable [ Name=p_partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=pssrn ]
+        Field=p_partkey
+      ]
+
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_acctbal]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_acctbal
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [p_partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=p_partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [p_mfgr]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=p_mfgr
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_address]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_address
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_phone]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_phone
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_comment]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_comment
+    ]
+  )
+]
+]
+FROM [  FunctionCall tpch.tmp2@0[
+  ]
+  AS
+  Variable [ Name=t2 ]
+,
+  FunctionCall tpch.tmp1@0[
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=p_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=p_partkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=ps_supplycost
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=ps_min_supplycost
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=s_acctbal
+  ]
+  DESC
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=n_name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=s_name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=p_partkey
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [100]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
new file mode 100644
index 0000000..8193892
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
@@ -0,0 +1,160 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_orderkey]
+    :
+    Variable [ Name=l_orderkey ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    Variable [ Name=o_orderdate ]
+  )
+  (
+    LiteralExpr [STRING] [o_shippriority]
+    :
+    Variable [ Name=o_shippriority ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_mktsegment
+        ]
+        =
+        LiteralExpr [STRING] [BUILDING]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+        <
+        LiteralExpr [STRING] [1995-03-15]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipdate
+        ]
+        >
+        LiteralExpr [STRING] [1995-03-15]
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=l_orderkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_orderkey
+  ]
+  Variable [ Name=o_orderdate ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderdate
+  ]
+  Variable [ Name=o_shippriority ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_shippriority
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+  Variable [ Name=o_orderdate ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [10]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
new file mode 100644
index 0000000..4dc7445
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q04_order_priority/q04_order_priority.3.ast
@@ -0,0 +1,109 @@
+DataverseUse tpch
+FunctionDecl tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [o_orderkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_orderkey
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=LineItem ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_commitdate
+        ]
+        <
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_receiptdate
+        ]
+      ]
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [order_priority]
+    :
+    Variable [ Name=o_orderpriority ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=o ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall tpch.tmp@0[
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=o_orderkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderdate
+      ]
+      >=
+      LiteralExpr [STRING] [1993-07-01]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderdate
+      ]
+      <
+      LiteralExpr [STRING] [1993-10-01]
+    ]
+  ]
+Groupby
+  Variable [ Name=o_orderpriority ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderpriority
+  ]
+  With
+  Variable [ Name=t ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=o_orderpriority ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
new file mode 100644
index 0000000..2b505fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
@@ -0,0 +1,344 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=s_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=n1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_nationkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Supplier]
+              ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Nation]
+                  ]
+                  AS
+                  Variable [ Name=n ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Region]
+                  ]
+                  AS
+                  Variable [ Name=r ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_regionkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=r ]
+                      Field=r_regionkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=n1 ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=n1 ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=s1 ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l1 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l1 ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderdate
+          ]
+          >=
+          LiteralExpr [STRING] [1990-01-01]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderdate
+          ]
+          <
+          LiteralExpr [STRING] [1995-01-01]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=o1 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=s_nationkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_custkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=o_custkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=n_name
+  ]
+  With
+  Variable [ Name=o1 ]
+  Variable [ Name=c ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=o1 ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
new file mode 100644
index 0000000..f802e5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
@@ -0,0 +1,78 @@
+DataverseUse tpch
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_extendedprice
+          ]
+          *
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_discount
+          ]
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipdate
+              ]
+              >=
+              LiteralExpr [STRING] [1994-01-01]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipdate
+              ]
+              <
+              LiteralExpr [STRING] [1995-01-01]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_discount
+              ]
+              >=
+              LiteralExpr [DOUBLE] [0.05]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_discount
+              ]
+              <=
+              LiteralExpr [DOUBLE] [0.07]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <
+              LiteralExpr [LONG] [24]
+            ]
+          ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
new file mode 100644
index 0000000..deed492
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q07_volume_shipping/q07_volume_shipping.3.ast
@@ -0,0 +1,417 @@
+DataverseUse tpch
+FunctionDecl q7_volume_shipping_tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [supp_nation]
+        :
+        FieldAccessor [
+          Variable [ Name=n1 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [cust_nation]
+        :
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=n1 ]
+          Field=n_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_nationkey
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Nation ]
+      AS
+      Variable [ Name=n1 ]
+,
+      Variable [ Name=Nation ]
+      AS
+      Variable [ Name=n2 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=n2 ]
+            Field=n_name
+          ]
+          =
+          LiteralExpr [STRING] [GERMANY]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=n1 ]
+            Field=n_name
+          ]
+          =
+          LiteralExpr [STRING] [GERMANY]
+        ]
+      ]
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [supp_nation]
+    :
+    Variable [ Name=supp_nation ]
+  )
+  (
+    LiteralExpr [STRING] [cust_nation]
+    :
+    Variable [ Name=cust_nation ]
+  )
+  (
+    LiteralExpr [STRING] [l_year]
+    :
+    Variable [ Name=l_year ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_shipdate]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_shipdate
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=c_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_nationkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_shipdate]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_shipdate
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [l_shipdate]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_shipdate
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [o_custkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [LineItem]
+              ]
+              AS
+              Variable [ Name=l ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Orders]
+              ]
+              AS
+              Variable [ Name=o ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=o ]
+                    Field=o_orderkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_orderkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_shipdate
+                  ]
+                  >=
+                  LiteralExpr [STRING] [1992-01-01]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_shipdate
+                  ]
+                  <=
+                  LiteralExpr [STRING] [1996-12-31]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=lo ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=o_custkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=loc ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Supplier]
+      ]
+      AS
+      Variable [ Name=s ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_suppkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_suppkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=locs ]
+,
+  FunctionCall tpch.q7_volume_shipping_tmp@0[
+  ]
+  AS
+  Variable [ Name=t ]
+]
+LetVariable [ Name=l_year0 ]
+  :=
+  FunctionCall tpch.get-year@1[
+    FieldAccessor [
+      Variable [ Name=locs ]
+      Field=l_shipdate
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=locs ]
+        Field=c_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=c_nationkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=locs ]
+        Field=s_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=s_nationkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=supp_nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=supp_nation
+  ]
+  Variable [ Name=cust_nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=cust_nation
+  ]
+  Variable [ Name=l_year ]
+  :=
+  Variable [ Name=l_year0 ]
+  With
+  Variable [ Name=l_year0 ]
+  Variable [ Name=locs ]
+  Variable [ Name=t ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=locs ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=supp_nation ]
+  ASC
+  Variable [ Name=cust_nation ]
+  ASC
+  Variable [ Name=l_year ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
new file mode 100644
index 0000000..f6dbd18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q08_national_market_share/q08_national_market_share.3.ast
@@ -0,0 +1,494 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [year]
+    :
+    Variable [ Name=year ]
+  )
+  (
+    LiteralExpr [STRING] [mkt_share]
+    :
+    OperatorExpr [
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FunctionCall tpch.switch-case@5[
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=s_name
+              ]
+              =
+              LiteralExpr [STRING] [BRAZIL]
+            ]
+            LiteralExpr [TRUE]
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=revenue
+            ]
+            LiteralExpr [FALSE]
+            LiteralExpr [DOUBLE] [0.0]
+          ]
+          ]
+          FROM [            Variable [ Name=t ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+      /
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=revenue
+          ]
+          ]
+          FROM [            Variable [ Name=t ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [year]
+        :
+        Variable [ Name=o_year ]
+      )
+      (
+        LiteralExpr [STRING] [revenue]
+        :
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=slnrcop ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=slnrcop ]
+              Field=l_discount
+            ]
+          ]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_name
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [o_orderdate]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=o_orderdate
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Supplier]
+          ]
+          AS
+          Variable [ Name=s ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [o_orderdate]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=o_orderdate
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=l_suppkey
+                ]
+              )
+            ]
+            ]
+            FROM [              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [o_orderdate]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=nrco ]
+                      Field=o_orderdate
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_partkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_partkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_discount]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_discount
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_extendedprice]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_extendedprice
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_suppkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [LineItem]
+                  ]
+                  AS
+                  Variable [ Name=l ]
+,
+                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [o_orderdate]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_orderdate
+                        ]
+                      )
+                      (
+                        LiteralExpr [STRING] [o_orderkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_orderkey
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Orders]
+                      ]
+                      AS
+                      Variable [ Name=o ]
+,
+                      (
+                        SELECT ELEMENT [
+                        RecordConstructor [
+                          (
+                            LiteralExpr [STRING] [c_custkey]
+                            :
+                            FieldAccessor [
+                              Variable [ Name=c ]
+                              Field=c_custkey
+                            ]
+                          )
+                        ]
+                        ]
+                        FROM [                          FunctionCall Metadata.dataset@1[
+                            LiteralExpr [STRING] [Customer]
+                          ]
+                          AS
+                          Variable [ Name=c ]
+,
+                          (
+                            SELECT ELEMENT [
+                            RecordConstructor [
+                              (
+                                LiteralExpr [STRING] [n_nationkey]
+                                :
+                                FieldAccessor [
+                                  Variable [ Name=n1 ]
+                                  Field=n_nationkey
+                                ]
+                              )
+                            ]
+                            ]
+                            FROM [                              FunctionCall Metadata.dataset@1[
+                                LiteralExpr [STRING] [Nation]
+                              ]
+                              AS
+                              Variable [ Name=n1 ]
+,
+                              FunctionCall Metadata.dataset@1[
+                                LiteralExpr [STRING] [Region]
+                              ]
+                              AS
+                              Variable [ Name=r1 ]
+                            ]
+                            Where
+                              OperatorExpr [
+                                OperatorExpr [
+                                  FieldAccessor [
+                                    Variable [ Name=n1 ]
+                                    Field=n_regionkey
+                                  ]
+                                  =
+                                  FieldAccessor [
+                                    Variable [ Name=r1 ]
+                                    Field=r_regionkey
+                                  ]
+                                ]
+                                and
+                                OperatorExpr [
+                                  FieldAccessor [
+                                    Variable [ Name=r1 ]
+                                    Field=r_name
+                                  ]
+                                  =
+                                  LiteralExpr [STRING] [AMERICA]
+                                ]
+                              ]
+                          )
+                          AS
+                          Variable [ Name=nr ]
+                        ]
+                        Where
+                          OperatorExpr [
+                            FieldAccessor [
+                              Variable [ Name=c ]
+                              Field=c_nationkey
+                            ]
+                            =
+                            FieldAccessor [
+                              Variable [ Name=nr ]
+                              Field=n_nationkey
+                            ]
+                          ]
+                      )
+                      AS
+                      Variable [ Name=nrc ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        FieldAccessor [
+                          Variable [ Name=nrc ]
+                          Field=c_custkey
+                        ]
+                        =
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_custkey
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=nrco ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=l ]
+                        Field=l_orderkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=nrco ]
+                        Field=o_orderkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=nrco ]
+                        Field=o_orderdate
+                      ]
+                      >=
+                      LiteralExpr [STRING] [1995-01-01]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=nrco ]
+                        Field=o_orderdate
+                      ]
+                      <
+                      LiteralExpr [STRING] [1996-12-31]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=lnrco ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Part]
+              ]
+              AS
+              Variable [ Name=p ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=p ]
+                    Field=p_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=lnrco ]
+                    Field=l_partkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=p ]
+                    Field=p_type
+                  ]
+                  =
+                  LiteralExpr [STRING] [ECONOMY ANODIZED STEEL]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=lnrcop ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=slnrcop ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=n2 ]
+    ]
+    LetVariable [ Name=o_year ]
+      :=
+      FunctionCall tpch.get-year@1[
+        FieldAccessor [
+          Variable [ Name=slnrcop ]
+          Field=o_orderdate
+        ]
+      ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=slnrcop ]
+          Field=s_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  Variable [ Name=year ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=year
+  ]
+  With
+  Variable [ Name=t ]
+
+Orderby
+  Variable [ Name=year ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
new file mode 100644
index 0000000..8052433
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
@@ -0,0 +1,454 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation]
+    :
+    Variable [ Name=nation ]
+  )
+  (
+    LiteralExpr [STRING] [o_year]
+    :
+    Variable [ Name=o_year ]
+  )
+  (
+    LiteralExpr [STRING] [sum_profit]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=pr ]
+          Field=amount
+        ]
+        ]
+        FROM [          Variable [ Name=profit ]
+          AS
+          Variable [ Name=pr ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation]
+        :
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_year]
+        :
+        Variable [ Name=o_year ]
+      )
+      (
+        LiteralExpr [STRING] [amount]
+        :
+        Variable [ Name=amount ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_quantity]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_quantity
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=ps_supplycost
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Part]
+          ]
+          AS
+          Variable [ Name=p ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_quantity]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_quantity
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_partkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_partkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_orderkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_orderkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [ps_supplycost]
+                :
+                FieldAccessor [
+                  Variable [ Name=ps ]
+                  Field=ps_supplycost
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Partsupp]
+              ]
+              AS
+              Variable [ Name=ps ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [l_suppkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_extendedprice]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_extendedprice
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_discount]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_discount
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_quantity]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_quantity
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_partkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_partkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_orderkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_orderkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [s_suppkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_suppkey
+                        ]
+                      )
+                      (
+                        LiteralExpr [STRING] [n_name]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_name
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Supplier]
+                      ]
+                      AS
+                      Variable [ Name=s ]
+,
+                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Nation]
+                      ]
+                      AS
+                      Variable [ Name=n ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_nationkey
+                        ]
+                        =
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_nationkey
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=s1 ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [LineItem]
+                  ]
+                  AS
+                  Variable [ Name=l ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=s_suppkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=l1 ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_suppkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_suppkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_partkey
+                  ]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=l2 ]
+        ]
+        Where
+          OperatorExpr [
+            FunctionCall tpch.contains@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_name
+              ]
+              LiteralExpr [STRING] [green]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l2 ]
+                Field=l_partkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l3 ]
+    ]
+    LetVariable [ Name=amount ]
+      :=
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=l3 ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        -
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=ps_supplycost
+          ]
+          *
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_quantity
+          ]
+        ]
+      ]
+    LetVariable [ Name=o_year ]
+      :=
+      FunctionCall tpch.get-year@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+      ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=l_orderkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=profit ]
+]
+Groupby
+  Variable [ Name=nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=nation
+  ]
+  Variable [ Name=o_year ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=o_year
+  ]
+  With
+  Variable [ Name=profit ]
+
+Orderby
+  Variable [ Name=nation ]
+  ASC
+  Variable [ Name=o_year ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.1.ast
new file mode 100644
index 0000000..d00a61f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
new file mode 100644
index 0000000..95cef5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item/q10_returned_item.3.ast
@@ -0,0 +1,372 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [c_acctbal]
+    :
+    Variable [ Name=c_acctbal ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_address]
+    :
+    Variable [ Name=c_address ]
+  )
+  (
+    LiteralExpr [STRING] [c_phone]
+    :
+    Variable [ Name=c_phone ]
+  )
+  (
+    LiteralExpr [STRING] [c_comment]
+    :
+    Variable [ Name=c_comment ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_address]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_phone]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_phone
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_comment]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_comment
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_discount
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [c_custkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_name]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=n ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_address]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_comment
+            ]
+          )
+          (
+            LiteralExpr [STRING] [o_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_orderkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Nation]
+          ]
+          AS
+          Variable [ Name=n ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=c ]
+                  Field=c_custkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                >=
+                LiteralExpr [STRING] [1993-10-01]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                <
+                LiteralExpr [STRING] [1994-01-01]
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=c ]
+                Field=c_nationkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=n ]
+                Field=n_nationkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=ocn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ocn ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_selectflag
+          ]
+          =
+          LiteralExpr [STRING] [R]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=locn ]
+]
+Groupby
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_custkey
+  ]
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_name
+  ]
+  Variable [ Name=c_acctbal ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_acctbal
+  ]
+  Variable [ Name=c_phone ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_phone
+  ]
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=n_name
+  ]
+  Variable [ Name=c_address ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_address
+  ]
+  Variable [ Name=c_comment ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_comment
+  ]
+  With
+  Variable [ Name=locn ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=locn ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [20]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
new file mode 100644
index 0000000..95cef5d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q10_returned_item_int64/q10_returned_item_int64.3.ast
@@ -0,0 +1,372 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [c_acctbal]
+    :
+    Variable [ Name=c_acctbal ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_address]
+    :
+    Variable [ Name=c_address ]
+  )
+  (
+    LiteralExpr [STRING] [c_phone]
+    :
+    Variable [ Name=c_phone ]
+  )
+  (
+    LiteralExpr [STRING] [c_comment]
+    :
+    Variable [ Name=c_comment ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_address]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_phone]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_phone
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_comment]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_comment
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_discount
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [c_custkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_name]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=n ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_address]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_comment
+            ]
+          )
+          (
+            LiteralExpr [STRING] [o_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_orderkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Nation]
+          ]
+          AS
+          Variable [ Name=n ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=c ]
+                  Field=c_custkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                >=
+                LiteralExpr [STRING] [1993-10-01]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                <
+                LiteralExpr [STRING] [1994-01-01]
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=c ]
+                Field=c_nationkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=n ]
+                Field=n_nationkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=ocn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ocn ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_selectflag
+          ]
+          =
+          LiteralExpr [STRING] [R]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=locn ]
+]
+Groupby
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_custkey
+  ]
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_name
+  ]
+  Variable [ Name=c_acctbal ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_acctbal
+  ]
+  Variable [ Name=c_phone ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_phone
+  ]
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=n_name
+  ]
+  Variable [ Name=c_address ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_address
+  ]
+  Variable [ Name=c_comment ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_comment
+  ]
+  With
+  Variable [ Name=locn ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=locn ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [20]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
new file mode 100644
index 0000000..6fb853e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q11_important_stock/q11_important_stock.3.ast
@@ -0,0 +1,230 @@
+DataverseUse tpch
+Query:
+LetVariable [ Name=sum ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_supplycost
+        ]
+        *
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_availqty
+        ]
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Partsupp]
+        ]
+        AS
+        Variable [ Name=ps ]
+,
+        (
+          SELECT ELEMENT [
+          RecordConstructor [
+            (
+              LiteralExpr [STRING] [s_suppkey]
+              :
+              FieldAccessor [
+                Variable [ Name=s ]
+                Field=s_suppkey
+              ]
+            )
+          ]
+          ]
+          FROM [            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [Supplier]
+            ]
+            AS
+            Variable [ Name=s ]
+,
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [Nation]
+            ]
+            AS
+            Variable [ Name=n ]
+          ]
+          Where
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=s ]
+                Field=s_nationkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=n ]
+                Field=n_nationkey
+              ]
+            ]
+        )
+        AS
+        Variable [ Name=sn ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=sn ]
+            Field=s_suppkey
+          ]
+        ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=ps_partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [part_value]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=part_value
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [ps_partkey]
+        :
+        Variable [ Name=ps_partkey ]
+      )
+      (
+        LiteralExpr [STRING] [part_value]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=ps_supplycost
+              ]
+              *
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=ps_availqty
+              ]
+            ]
+            ]
+            FROM [              Variable [ Name=ps ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Partsupp]
+      ]
+      AS
+      Variable [ Name=ps ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [s_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Supplier]
+          ]
+          AS
+          Variable [ Name=s ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Nation]
+          ]
+          AS
+          Variable [ Name=n ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_nationkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=n ]
+              Field=n_nationkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=sn ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_suppkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=sn ]
+          Field=s_suppkey
+        ]
+      ]
+    Groupby
+      Variable [ Name=ps_partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_partkey
+      ]
+      With
+      Variable [ Name=ps ]
+      Variable [ Name=sn ]
+      Variable [ Name=sum ]
+
+  )
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=part_value
+    ]
+    >
+    OperatorExpr [
+      Variable [ Name=sum ]
+      *
+      LiteralExpr [DOUBLE] [1.0E-5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=part_value
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
new file mode 100644
index 0000000..c478139
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q12_shipping/q12_shipping.3.ast
@@ -0,0 +1,192 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_shipmode]
+    :
+    Variable [ Name=l_shipmode ]
+  )
+  (
+    LiteralExpr [STRING] [high_line_count]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FunctionCall tpch.switch-case@5[
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [1-URGENT]
+            ]
+            or
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [2-HIGH]
+            ]
+          ]
+          LiteralExpr [TRUE]
+          LiteralExpr [LONG] [1]
+          LiteralExpr [FALSE]
+          LiteralExpr [LONG] [0]
+        ]
+        ]
+        FROM [          Variable [ Name=o ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [low_line_count]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FunctionCall tpch.switch-case@5[
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [1-URGENT]
+            ]
+            or
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [2-HIGH]
+            ]
+          ]
+          LiteralExpr [TRUE]
+          LiteralExpr [LONG] [0]
+          LiteralExpr [FALSE]
+          LiteralExpr [LONG] [1]
+        ]
+        ]
+        FROM [          Variable [ Name=o ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_commitdate
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_receiptdate
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_shipdate
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_commitdate
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_receiptdate
+      ]
+      >=
+      LiteralExpr [STRING] [1994-01-01]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_receiptdate
+      ]
+      <
+      LiteralExpr [STRING] [1995-01-01]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipmode
+        ]
+        =
+        LiteralExpr [STRING] [MAIL]
+      ]
+      or
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipmode
+        ]
+        =
+        LiteralExpr [STRING] [SHIP]
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=l_shipmode ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_shipmode
+  ]
+  With
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=l_shipmode ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
new file mode 100644
index 0000000..2b22632
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q13_customer_distribution/q13_customer_distribution.3.ast
@@ -0,0 +1,147 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_count]
+    :
+    Variable [ Name=c_count ]
+  )
+  (
+    LiteralExpr [STRING] [custdist]
+    :
+    Variable [ Name=custdist ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        Variable [ Name=c_custkey ]
+      )
+      (
+        LiteralExpr [STRING] [c_count]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=o_orderkey_count
+            ]
+            ]
+            FROM [              Variable [ Name=co ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [c_custkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [o_orderkey_count]
+            :
+            FunctionCall tpch.count@1[
+              (
+                SELECT ELEMENT [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderkey
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Orders]
+                  ]
+                  AS
+                  Variable [ Name=o ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=c ]
+                        Field=c_custkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=o ]
+                        Field=o_custkey
+                      ]
+                    ]
+                    and
+                    FunctionCall tpch.not@1[
+                      FunctionCall tpch.like@2[
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_comment
+                        ]
+                        LiteralExpr [STRING] [%special%requests%]
+                      ]
+                    ]
+                  ]
+              )
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+        ]
+      )
+      AS
+      Variable [ Name=co ]
+    ]
+    Groupby
+      Variable [ Name=c_custkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=co ]
+        Field=c_custkey
+      ]
+      With
+      Variable [ Name=co ]
+
+  )
+  AS
+  Variable [ Name=gco ]
+]
+Groupby
+  Variable [ Name=c_count ]
+  :=
+  FieldAccessor [
+    Variable [ Name=gco ]
+    Field=c_count
+  ]
+  With
+  Variable [ Name=gco ]
+
+LetVariable [ Name=custdist ]
+  :=
+  FunctionCall tpch.count@1[
+    Variable [ Name=gco ]
+  ]
+Orderby
+  Variable [ Name=custdist ]
+  DESC
+  Variable [ Name=c_count ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
new file mode 100644
index 0000000..57b4c73
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q14_promotion_effect/q14_promotion_effect.3.ast
@@ -0,0 +1,123 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+OperatorExpr [
+  LiteralExpr [DOUBLE] [100.0]
+  *
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      FunctionCall tpch.switch-case@5[
+        FunctionCall tpch.like@2[
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=p_type
+          ]
+          LiteralExpr [STRING] [PROMO%]
+        ]
+        LiteralExpr [TRUE]
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        LiteralExpr [FALSE]
+        LiteralExpr [DOUBLE] [0.0]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+  /
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Part]
+  ]
+  AS
+  Variable [ Name=p ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=p ]
+        Field=p_partkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_shipdate
+      ]
+      >=
+      LiteralExpr [STRING] [1995-09-01]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_shipdate
+      ]
+      <
+      LiteralExpr [STRING] [1995-10-01]
+    ]
+  ]
+Groupby
+  Variable [ Name=t ]
+  :=
+  LiteralExpr [LONG] [1]
+  With
+  Variable [ Name=p ]
+  Variable [ Name=l ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
new file mode 100644
index 0000000..b19616d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q15_top_supplier/q15_top_supplier.3.ast
@@ -0,0 +1,189 @@
+DataverseUse tpch
+FunctionDecl revenue([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [supplier_no]
+        :
+        Variable [ Name=l_suppkey ]
+      )
+      (
+        LiteralExpr [STRING] [total_revenue]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=l_extendedprice
+              ]
+              *
+              OperatorExpr [
+                LiteralExpr [LONG] [1]
+                -
+                FieldAccessor [
+                  Variable [ Name=i ]
+                  Field=l_discount
+                ]
+              ]
+            ]
+            ]
+            FROM [              Variable [ Name=l ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=LineItem ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_shipdate
+          ]
+          >=
+          LiteralExpr [STRING] [1996-01-01]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_shipdate
+          ]
+          <
+          LiteralExpr [STRING] [1996-04-01]
+        ]
+      ]
+    Groupby
+      Variable [ Name=l_suppkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_suppkey
+      ]
+
+  )
+}
+
+Query:
+LetVariable [ Name=m ]
+  :=
+  FunctionCall tpch.max@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=r2 ]
+        Field=total_revenue
+      ]
+      ]
+      FROM [        FunctionCall tpch.revenue@0[
+        ]
+        AS
+        Variable [ Name=r2 ]
+      ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_suppkey]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_suppkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_address]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_address
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_phone]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_phone
+    ]
+  )
+  (
+    LiteralExpr [STRING] [total_revenue]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=total_revenue
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Supplier]
+  ]
+  AS
+  Variable [ Name=s ]
+,
+  FunctionCall tpch.revenue@0[
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=s ]
+        Field=s_suppkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=supplier_no
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=total_revenue
+      ]
+      <
+      OperatorExpr [
+        Variable [ Name=m ]
+        +
+        LiteralExpr [DOUBLE] [1.0E-9]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=total_revenue
+      ]
+      >
+      OperatorExpr [
+        Variable [ Name=m ]
+        -
+        LiteralExpr [DOUBLE] [1.0E-9]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
new file mode 100644
index 0000000..dc55293
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
@@ -0,0 +1,361 @@
+DataverseUse tpch
+FunctionDecl tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [p_brand]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=p_brand
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_type]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=p_type
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_size]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=p_size
+        ]
+      )
+      (
+        LiteralExpr [STRING] [ps_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=ps_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [p_brand]
+            :
+            FieldAccessor [
+              Variable [ Name=p ]
+              Field=p_brand
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_type]
+            :
+            FieldAccessor [
+              Variable [ Name=p ]
+              Field=p_type
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_size]
+            :
+            FieldAccessor [
+              Variable [ Name=p ]
+              Field=p_size
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=Partsupp ]
+          AS
+          Variable [ Name=ps ]
+,
+          Variable [ Name=Part ]
+          AS
+          Variable [ Name=p ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=ps ]
+                Field=ps_partkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              !=
+              LiteralExpr [STRING] [Brand#45]
+            ]
+            and
+            FunctionCall tpch.not@1[
+              FunctionCall tpch.like@2[
+                FieldAccessor [
+                  Variable [ Name=p ]
+                  Field=p_type
+                ]
+                LiteralExpr [STRING] [MEDIUM POLISHED%]
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=psp ]
+,
+      Variable [ Name=Supplier ]
+      AS
+      Variable [ Name=s ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=psp ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=s ]
+            Field=s_suppkey
+          ]
+        ]
+        and
+        FunctionCall tpch.not@1[
+          FunctionCall tpch.like@2[
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_comment
+            ]
+            LiteralExpr [STRING] [%Customer%Complaints%]
+          ]
+        ]
+      ]
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [p_brand]
+    :
+    Variable [ Name=p_brand ]
+  )
+  (
+    LiteralExpr [STRING] [p_type]
+    :
+    Variable [ Name=p_type ]
+  )
+  (
+    LiteralExpr [STRING] [p_size]
+    :
+    Variable [ Name=p_size ]
+  )
+  (
+    LiteralExpr [STRING] [supplier_cnt]
+    :
+    Variable [ Name=supplier_cnt ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [p_brand]
+        :
+        Variable [ Name=p_brand1 ]
+      )
+      (
+        LiteralExpr [STRING] [p_type]
+        :
+        Variable [ Name=p_type1 ]
+      )
+      (
+        LiteralExpr [STRING] [p_size]
+        :
+        Variable [ Name=p_size1 ]
+      )
+      (
+        LiteralExpr [STRING] [ps_suppkey]
+        :
+        Variable [ Name=ps_suppkey1 ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall tpch.tmp@0[
+      ]
+      AS
+      Variable [ Name=t ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [49]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [14]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [23]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [45]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [19]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [3]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [36]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [9]
+        ]
+      ]
+    Groupby
+      Variable [ Name=p_brand1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=p_brand
+      ]
+      Variable [ Name=p_type1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=p_type
+      ]
+      Variable [ Name=p_size1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=p_size
+      ]
+      Variable [ Name=ps_suppkey1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=ps_suppkey
+      ]
+      With
+      Variable [ Name=t ]
+
+  )
+  AS
+  Variable [ Name=t2 ]
+]
+Groupby
+  Variable [ Name=p_brand ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t2 ]
+    Field=p_brand
+  ]
+  Variable [ Name=p_type ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t2 ]
+    Field=p_type
+  ]
+  Variable [ Name=p_size ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t2 ]
+    Field=p_size
+  ]
+  With
+  Variable [ Name=t2 ]
+
+LetVariable [ Name=supplier_cnt ]
+  :=
+  FunctionCall tpch.count@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=ps_suppkey
+      ]
+      ]
+      FROM [        Variable [ Name=t2 ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=supplier_cnt ]
+  DESC
+  Variable [ Name=p_brand ]
+  ASC
+  Variable [ Name=p_type ]
+  ASC
+  Variable [ Name=p_size ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
new file mode 100644
index 0000000..19e5d78
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_large_gby_variant/q17_large_gby_variant.3.ast
@@ -0,0 +1,222 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t_partkey]
+    :
+    Variable [ Name=l_partkey ]
+  )
+  (
+    LiteralExpr [STRING] [t_count]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_quantity]
+    :
+    OperatorExpr [
+      LiteralExpr [DOUBLE] [0.2]
+      *
+      FunctionCall tpch.avg@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_quantity
+          ]
+          ]
+          FROM [            Variable [ Name=l ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_suppkey]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_suppkey
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_linenumber]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_linenumber
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_extendedprice]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_discount]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_tax]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_tax
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_shipdate]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_shipdate
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_min_commitdate]
+    :
+    FunctionCall tpch.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_commitdate
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_min_receiptdate]
+    :
+    FunctionCall tpch.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_receiptdate
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_comment]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_comment
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Groupby
+  Variable [ Name=l_partkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_partkey
+  ]
+  With
+  Variable [ Name=l ]
+
+Orderby
+  Variable [ Name=l_partkey ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
new file mode 100644
index 0000000..845240a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q17_small_quantity_order_revenue/q17_small_quantity_order_revenue.3.ast
@@ -0,0 +1,134 @@
+DataverseUse tpch
+FunctionDecl tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [t_partkey]
+        :
+        Variable [ Name=l_partkey ]
+      )
+      (
+        LiteralExpr [STRING] [t_avg_quantity]
+        :
+        OperatorExpr [
+          LiteralExpr [DOUBLE] [0.2]
+          *
+          FunctionCall tpch.avg@1[
+            (
+              SELECT ELEMENT [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=l_quantity
+              ]
+              ]
+              FROM [                Variable [ Name=l ]
+                AS
+                Variable [ Name=i ]
+              ]
+            )
+          ]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=LineItem ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Groupby
+      Variable [ Name=l_partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_partkey
+      ]
+
+  )
+}
+
+Query:
+SELECT ELEMENT [
+OperatorExpr [
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_extendedprice
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [LineItem]
+        ]
+        AS
+        Variable [ Name=l ]
+,
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Part]
+        ]
+        AS
+        Variable [ Name=p ]
+,
+        FunctionCall tpch.tmp@0[
+        ]
+        AS
+        Variable [ Name=t ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_partkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              =
+              LiteralExpr [STRING] [MED BOX]
+            ]
+          ]
+          and
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=t ]
+                Field=t_partkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <
+              FieldAccessor [
+                Variable [ Name=t ]
+                Field=t_avg_quantity
+              ]
+            ]
+          ]
+        ]
+    )
+  ]
+  /
+  LiteralExpr [DOUBLE] [7.0]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
new file mode 100644
index 0000000..edf6190
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q18_large_volume_customer/q18_large_volume_customer.3.ast
@@ -0,0 +1,211 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    Variable [ Name=o_orderkey ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    Variable [ Name=o_orderdate ]
+  )
+  (
+    LiteralExpr [STRING] [o_totalprice]
+    :
+    Variable [ Name=o_totalprice ]
+  )
+  (
+    LiteralExpr [STRING] [sum_quantity]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=j ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=j ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [t_sum_quantity]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_quantity
+            ]
+            ]
+            FROM [              Variable [ Name=l ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      With
+      Variable [ Name=l ]
+      Variable [ Name=c ]
+      Variable [ Name=o ]
+
+  )
+  AS
+  Variable [ Name=t ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_custkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=l_orderkey
+        ]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=t_sum_quantity
+        ]
+        >
+        LiteralExpr [LONG] [30]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_name
+  ]
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_custkey
+  ]
+  Variable [ Name=o_orderkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  Variable [ Name=o_orderdate ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderdate
+  ]
+  Variable [ Name=o_totalprice ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_totalprice
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=t ]
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=o_totalprice ]
+  DESC
+  Variable [ Name=o_orderdate ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [100]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
new file mode 100644
index 0000000..46e01a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q19_discounted_revenue/q19_discounted_revenue.3.ast
@@ -0,0 +1,270 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall tpch.sum@1[
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_discount
+        ]
+      ]
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Part]
+      ]
+      AS
+      Variable [ Name=p ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              =
+              LiteralExpr [STRING] [Brand#12]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              LiteralExpr [STRING] [SM CASE||SM BOX||SM PACK||SM PKG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <=
+              LiteralExpr [LONG] [11]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              <=
+              LiteralExpr [LONG] [5]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipmode
+              ]
+              LiteralExpr [STRING] [AIR||AIR REG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipinstruct
+              ]
+              =
+              LiteralExpr [STRING] [DELIVER IN PERSON]
+            ]
+          ]
+          or
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              =
+              LiteralExpr [STRING] [Brand#23]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              LiteralExpr [STRING] [MED BAG||MED BOX||MED PKG||MED PACK]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              >=
+              LiteralExpr [LONG] [10]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <=
+              LiteralExpr [LONG] [20]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              <=
+              LiteralExpr [LONG] [10]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipmode
+              ]
+              LiteralExpr [STRING] [AIR||AIR REG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipinstruct
+              ]
+              =
+              LiteralExpr [STRING] [DELIVER IN PERSON]
+            ]
+          ]
+          or
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              =
+              LiteralExpr [STRING] [Brand#34]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              LiteralExpr [STRING] [LG CASE||LG BOX||LG PACK||LG PKG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              >=
+              LiteralExpr [LONG] [20]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <=
+              LiteralExpr [LONG] [30]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              <=
+              LiteralExpr [LONG] [15]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipmode
+              ]
+              LiteralExpr [STRING] [AIR||AIR REG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipinstruct
+              ]
+              =
+              LiteralExpr [STRING] [DELIVER IN PERSON]
+            ]
+          ]
+        ]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
new file mode 100644
index 0000000..fda99ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
@@ -0,0 +1,290 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    FieldAccessor [
+      Variable [ Name=t4 ]
+      Field=s_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_address]
+    :
+    FieldAccessor [
+      Variable [ Name=t4 ]
+      Field=s_address
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [ps_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=pst1 ]
+          Field=ps_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_partkey]
+            :
+            Variable [ Name=l_partkey ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            Variable [ Name=l_suppkey ]
+          )
+          (
+            LiteralExpr [STRING] [sum_quantity]
+            :
+            OperatorExpr [
+              LiteralExpr [DOUBLE] [0.5]
+              *
+              FunctionCall tpch.sum@1[
+                (
+                  SELECT ELEMENT [
+                  FieldAccessor [
+                    Variable [ Name=i ]
+                    Field=l_quantity
+                  ]
+                  ]
+                  FROM [                    Variable [ Name=l ]
+                    AS
+                    Variable [ Name=i ]
+                  ]
+                )
+              ]
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Groupby
+          Variable [ Name=l_partkey ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_partkey
+          ]
+          Variable [ Name=l_suppkey ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_suppkey
+          ]
+          With
+          Variable [ Name=l ]
+
+      )
+      AS
+      Variable [ Name=t2 ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [ps_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_availqty]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_availqty
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Partsupp]
+          ]
+          AS
+          Variable [ Name=ps ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [p_partkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=p ]
+                  Field=p_partkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Part]
+              ]
+              AS
+              Variable [ Name=p ]
+            ]
+          )
+          AS
+          Variable [ Name=t1 ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=p_partkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=pst1 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=pst1 ]
+            Field=ps_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=l_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=pst1 ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=l_suppkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=pst1 ]
+            Field=ps_availqty
+          ]
+          >
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sum_quantity
+          ]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t3 ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_address]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Supplier]
+      ]
+      AS
+      Variable [ Name=s ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=n ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t4 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t3 ]
+      Field=ps_suppkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=t4 ]
+      Field=s_suppkey
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t4 ]
+    Field=s_name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
new file mode 100644
index 0000000..c471683
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
@@ -0,0 +1,467 @@
+DataverseUse tpch
+FunctionDecl tmp1([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [count_suppkey]
+        :
+        FunctionCall tpch.count@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+      (
+        LiteralExpr [STRING] [max_suppkey]
+        :
+        FunctionCall tpch.max@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            Variable [ Name=l_orderkey1 ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            Variable [ Name=l_suppkey1 ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=LineItem ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Groupby
+          Variable [ Name=l_orderkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          Variable [ Name=l_suppkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_suppkey
+          ]
+
+      )
+      AS
+      Variable [ Name=l2 ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l2 ]
+        Field=l_orderkey
+      ]
+
+  )
+}
+
+FunctionDecl tmp2([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [count_suppkey]
+        :
+        FunctionCall tpch.count@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+      (
+        LiteralExpr [STRING] [max_suppkey]
+        :
+        FunctionCall tpch.max@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            Variable [ Name=l_orderkey1 ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            Variable [ Name=l_suppkey1 ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=LineItem ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_receiptdate
+            ]
+            >
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_commitdate
+            ]
+          ]
+        Groupby
+          Variable [ Name=l_orderkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          Variable [ Name=l_suppkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_suppkey
+          ]
+
+      )
+      AS
+      Variable [ Name=l2 ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l2 ]
+        Field=l_orderkey
+      ]
+
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    Variable [ Name=s_name ]
+  )
+  (
+    LiteralExpr [STRING] [numwait]
+    :
+    Variable [ Name=numwait ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=t3 ]
+          Field=s_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t3 ]
+          Field=l_suppkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=l_orderkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [count_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=count_suppkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [max_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=max_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [s_name]
+            :
+            FieldAccessor [
+              Variable [ Name=ns ]
+              Field=s_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Nation]
+              ]
+              AS
+              Variable [ Name=n ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Supplier]
+              ]
+              AS
+              Variable [ Name=s ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=n ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=ns ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+,
+          FunctionCall tpch.tmp1@0[
+          ]
+          AS
+          Variable [ Name=t1 ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=ns ]
+                  Field=s_suppkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_suppkey
+                ]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_receiptdate
+                ]
+                >
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_commitdate
+                ]
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=o ]
+                Field=o_orderkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_orderkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_orderkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=l_orderkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=t3 ]
+,
+      FunctionCall tpch.tmp2@0[
+      ]
+      AS
+      Variable [ Name=t2 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=count_suppkey
+          ]
+          >=
+          LiteralExpr [LONG] [0]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t3 ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=l_orderkey
+          ]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t4 ]
+]
+Groupby
+  Variable [ Name=s_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t4 ]
+    Field=s_name
+  ]
+  With
+  Variable [ Name=t4 ]
+
+LetVariable [ Name=numwait ]
+  :=
+  FunctionCall tpch.count@1[
+    Variable [ Name=t4 ]
+  ]
+Orderby
+  Variable [ Name=numwait ]
+  DESC
+  Variable [ Name=s_name ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ast
new file mode 100644
index 0000000..69d3aa8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
new file mode 100644
index 0000000..8efbfe5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
@@ -0,0 +1,133 @@
+DataverseUse tpch
+FunctionDecl q22_customer_tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [cntrycode]
+        :
+        FunctionCall tpch.substring@3[
+          FieldAccessor [
+            Variable [ Name=c ]
+            Field=c_phone
+          ]
+          LiteralExpr [LONG] [1]
+          LiteralExpr [LONG] [2]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Customer ]
+      AS
+      Variable [ Name=c ]
+    ]
+  )
+}
+
+Query:
+LetVariable [ Name=avg ]
+  :=
+  FunctionCall tpch.avg@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_acctbal
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=c ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=c ]
+            Field=c_acctbal
+          ]
+          >
+          LiteralExpr [DOUBLE] [0.0]
+        ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cntrycode]
+    :
+    Variable [ Name=cntrycode ]
+  )
+  (
+    LiteralExpr [STRING] [numcust]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=ct ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [totacctbal]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=c_acctbal
+        ]
+        ]
+        FROM [          Variable [ Name=ct ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall tpch.q22_customer_tmp@0[
+  ]
+  AS
+  Variable [ Name=ct ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=ct ]
+      Field=c_acctbal
+    ]
+    >
+    Variable [ Name=avg ]
+  ]
+Groupby
+  Variable [ Name=cntrycode ]
+  :=
+  FieldAccessor [
+    Variable [ Name=ct ]
+    Field=cntrycode
+  ]
+  With
+  Variable [ Name=ct ]
+  Variable [ Name=avg ]
+
+Orderby
+  Variable [ Name=cntrycode ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.1.ast
new file mode 100644
index 0000000..e788f46
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
new file mode 100644
index 0000000..3776535
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue601/query-issue601.3.ast
@@ -0,0 +1,34 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_linenumber]
+    :
+    Variable [ Name=l_linenumber ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Groupby
+  Variable [ Name=l_linenumber ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linenumber
+  ]
+  With
+  Variable [ Name=l ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.1.ast
new file mode 100644
index 0000000..5e27e8c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_selectflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType)is an external dataset
+DatasetDecl Orders(OrderType)is an external dataset
+DatasetDecl Supplier(SupplierType)is an external dataset
+DatasetDecl Region(RegionType)is an external dataset
+DatasetDecl Nation(NationType)is an external dataset
+DatasetDecl Part(PartType)is an external dataset
+DatasetDecl Partsupp(PartSuppType)is an external dataset
+DatasetDecl Customer(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
new file mode 100644
index 0000000..8052433
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue638/query-issue638.3.ast
@@ -0,0 +1,454 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation]
+    :
+    Variable [ Name=nation ]
+  )
+  (
+    LiteralExpr [STRING] [o_year]
+    :
+    Variable [ Name=o_year ]
+  )
+  (
+    LiteralExpr [STRING] [sum_profit]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=pr ]
+          Field=amount
+        ]
+        ]
+        FROM [          Variable [ Name=profit ]
+          AS
+          Variable [ Name=pr ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation]
+        :
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_year]
+        :
+        Variable [ Name=o_year ]
+      )
+      (
+        LiteralExpr [STRING] [amount]
+        :
+        Variable [ Name=amount ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_quantity]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_quantity
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=ps_supplycost
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Part]
+          ]
+          AS
+          Variable [ Name=p ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_quantity]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_quantity
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_partkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_partkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_orderkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_orderkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [ps_supplycost]
+                :
+                FieldAccessor [
+                  Variable [ Name=ps ]
+                  Field=ps_supplycost
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Partsupp]
+              ]
+              AS
+              Variable [ Name=ps ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [l_suppkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_extendedprice]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_extendedprice
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_discount]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_discount
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_quantity]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_quantity
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_partkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_partkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_orderkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_orderkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [s_suppkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_suppkey
+                        ]
+                      )
+                      (
+                        LiteralExpr [STRING] [n_name]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_name
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Supplier]
+                      ]
+                      AS
+                      Variable [ Name=s ]
+,
+                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Nation]
+                      ]
+                      AS
+                      Variable [ Name=n ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_nationkey
+                        ]
+                        =
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_nationkey
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=s1 ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [LineItem]
+                  ]
+                  AS
+                  Variable [ Name=l ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=s_suppkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=l1 ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_suppkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_suppkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_partkey
+                  ]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=l2 ]
+        ]
+        Where
+          OperatorExpr [
+            FunctionCall tpch.contains@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_name
+              ]
+              LiteralExpr [STRING] [green]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l2 ]
+                Field=l_partkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l3 ]
+    ]
+    LetVariable [ Name=amount ]
+      :=
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=l3 ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        -
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=ps_supplycost
+          ]
+          *
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_quantity
+          ]
+        ]
+      ]
+    LetVariable [ Name=o_year ]
+      :=
+      FunctionCall tpch.get-year@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+      ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=l_orderkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=profit ]
+]
+Groupby
+  Variable [ Name=nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=nation
+  ]
+  Variable [ Name=o_year ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=o_year
+  ]
+  With
+  Variable [ Name=profit ]
+
+Orderby
+  Variable [ Name=nation ]
+  ASC
+  Variable [ Name=o_year ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.1.ast
new file mode 100644
index 0000000..c0608a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
new file mode 100644
index 0000000..4a81b19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
@@ -0,0 +1,215 @@
+DataverseUse tpch
+Query:
+LetVariable [ Name=t ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [n_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_name
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=nation ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [SelectedNation]
+      ]
+      AS
+      Variable [ Name=sn ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=sn ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+LetVariable [ Name=X ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation_key]
+        :
+        Variable [ Name=nation_key ]
+      )
+      (
+        LiteralExpr [STRING] [order_date]
+        :
+        Variable [ Name=orderdate ]
+      )
+      (
+        LiteralExpr [STRING] [sum_price]
+        :
+        Variable [ Name=sum ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=t ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Customer]
+      ]
+      AS
+      Variable [ Name=customer ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=orders ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=orders ]
+            Field=o_custkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_custkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_nationkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=n ]
+            Field=n_nationkey
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=orderdate ]
+      :=
+      FieldAccessor [
+        Variable [ Name=orders ]
+        Field=o_orderdate
+      ]
+      Variable [ Name=nation_key ]
+      :=
+      FieldAccessor [
+        Variable [ Name=n ]
+        Field=n_nationkey
+      ]
+      With
+      Variable [ Name=orders ]
+      Variable [ Name=n ]
+      Variable [ Name=customer ]
+      Variable [ Name=X ]
+      Variable [ Name=t ]
+
+    LetVariable [ Name=sum ]
+      :=
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_totalprice
+          ]
+          ]
+          FROM [            Variable [ Name=orders ]
+            AS
+            Variable [ Name=o ]
+          ]
+        )
+      ]
+  )
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    Variable [ Name=nation_key ]
+  )
+  (
+    LiteralExpr [STRING] [sum_price]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [orderdate]
+          :
+          FieldAccessor [
+            Variable [ Name=y ]
+            Field=order_date
+          ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          FieldAccessor [
+            Variable [ Name=y ]
+            Field=sum_price
+          ]
+        )
+      ]
+      ]
+      FROM [        Variable [ Name=x ]
+        AS
+        Variable [ Name=y ]
+      ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=y ]
+          Field=sum_price
+        ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  Variable [ Name=X ]
+  AS
+  Variable [ Name=x ]
+]
+Groupby
+  Variable [ Name=nation_key ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=nation_key
+  ]
+  With
+  Variable [ Name=x ]
+  Variable [ Name=X ]
+  Variable [ Name=t ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.1.ast
new file mode 100644
index 0000000..c0608a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
new file mode 100644
index 0000000..085714d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
@@ -0,0 +1,177 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    Variable [ Name=nation_key ]
+  )
+  (
+    LiteralExpr [STRING] [sum_price]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [orderdate]
+          :
+          Variable [ Name=od ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          Variable [ Name=sum ]
+        )
+      ]
+      ]
+      FROM [        Variable [ Name=x ]
+        AS
+        Variable [ Name=i ]
+      ]
+      Groupby
+        Variable [ Name=od ]
+        :=
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=order_date
+        ]
+        With
+        Variable [ Name=i ]
+        Variable [ Name=x ]
+
+      LetVariable [ Name=sum ]
+        :=
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=sum_price
+            ]
+            ]
+            FROM [              Variable [ Name=i ]
+              AS
+              Variable [ Name=s ]
+            ]
+          )
+        ]
+      Orderby
+        Variable [ Name=sum ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation_key]
+        :
+        Variable [ Name=nation_key ]
+      )
+      (
+        LiteralExpr [STRING] [order_date]
+        :
+        Variable [ Name=orderdate ]
+      )
+      (
+        LiteralExpr [STRING] [sum_price]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_totalprice
+            ]
+            ]
+            FROM [              Variable [ Name=orders ]
+              AS
+              Variable [ Name=o ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Customer]
+      ]
+      AS
+      Variable [ Name=customer ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=orders ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=orders ]
+            Field=o_custkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_custkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_nationkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=n ]
+            Field=n_nationkey
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=orderdate ]
+      :=
+      FieldAccessor [
+        Variable [ Name=orders ]
+        Field=o_orderdate
+      ]
+      Variable [ Name=nation_key ]
+      :=
+      FieldAccessor [
+        Variable [ Name=n ]
+        Field=n_nationkey
+      ]
+      With
+      Variable [ Name=orders ]
+      Variable [ Name=n ]
+      Variable [ Name=customer ]
+
+  )
+  AS
+  Variable [ Name=x ]
+]
+Groupby
+  Variable [ Name=nation_key ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=nation_key
+  ]
+  With
+  Variable [ Name=x ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.1.ast
new file mode 100644
index 0000000..003faa7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
new file mode 100644
index 0000000..dcd0269
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
@@ -0,0 +1,139 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [aggregates]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [order_date]
+          :
+          Variable [ Name=orderdate ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          Variable [ Name=sum ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Orders]
+        ]
+        AS
+        Variable [ Name=orders ]
+,
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=customer ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=orders ]
+              Field=o_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_custkey
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_nationkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=nation ]
+              Field=n_nationkey
+            ]
+          ]
+        ]
+      Groupby
+        Variable [ Name=orderdate ]
+        :=
+        FieldAccessor [
+          Variable [ Name=orders ]
+          Field=o_orderdate
+        ]
+        With
+        Variable [ Name=orders ]
+        Variable [ Name=customer ]
+        Variable [ Name=nation ]
+        Variable [ Name=sn ]
+
+      LetVariable [ Name=sum ]
+        :=
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_totalprice
+            ]
+            ]
+            FROM [              Variable [ Name=orders ]
+              AS
+              Variable [ Name=o ]
+            ]
+          )
+        ]
+      Orderby
+        Variable [ Name=sum ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Nation]
+  ]
+  AS
+  Variable [ Name=nation ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [SelectedNation]
+  ]
+  AS
+  Variable [ Name=sn ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=sn ]
+      Field=sn_nationkey
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.1.ast
new file mode 100644
index 0000000..0abc90d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast
new file mode 100644
index 0000000..b8d2c7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast
@@ -0,0 +1,53 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_returnflag
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_linestatus
+    ]
+  )
+  (
+    LiteralExpr [STRING] [l_shipmode]
+    :
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipmode
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_shipmode
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.1.ast
new file mode 100644
index 0000000..f60dcd7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.1.ast
@@ -0,0 +1,9 @@
+DataverseUse tpch
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Regions_group_no_agg(RegionType) partitioned by [[r_regionkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast
new file mode 100644
index 0000000..8a7df20
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast
@@ -0,0 +1,25 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+Variable [ Name=name ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Regions_group_no_agg]
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Groupby
+  Variable [ Name=name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=r ]
+    Field=r_name
+  ]
+  With
+  Variable [ Name=r ]
+
+Orderby
+  Variable [ Name=name ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.1.ast
new file mode 100644
index 0000000..c0608a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast
new file mode 100644
index 0000000..ccaa2ee
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast
@@ -0,0 +1,139 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [aggregates]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [order_date]
+          :
+          Variable [ Name=orderdate ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          Variable [ Name=sum ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Orders]
+        ]
+        AS
+        Variable [ Name=orders ]
+,
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=customer ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=orders ]
+              Field=o_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_custkey
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_nationkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=nation ]
+              Field=n_nationkey
+            ]
+          ]
+        ]
+      Groupby
+        Variable [ Name=orderdate ]
+        :=
+        FieldAccessor [
+          Variable [ Name=orders ]
+          Field=o_orderdate
+        ]
+        With
+        Variable [ Name=orders ]
+        Variable [ Name=customer ]
+        Variable [ Name=nation ]
+        Variable [ Name=sn ]
+
+      LetVariable [ Name=sum ]
+        :=
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_totalprice
+            ]
+            ]
+            FROM [              Variable [ Name=orders ]
+              AS
+              Variable [ Name=o ]
+            ]
+          )
+        ]
+      Orderby
+        Variable [ Name=sum ]
+        ASC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Nation]
+  ]
+  AS
+  Variable [ Name=nation ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [SelectedNation]
+  ]
+  AS
+  Variable [ Name=sn ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=sn ]
+      Field=n_nationkey
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast
new file mode 100644
index 0000000..3535ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
new file mode 100644
index 0000000..40474c7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
@@ -0,0 +1,218 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [sum_qty]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_base_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_charge]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            +
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_tax
+            ]
+          ]
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_qty]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_price]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_disc]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
new file mode 100644
index 0000000..52df01f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
@@ -0,0 +1,755 @@
+DataverseUse tpch
+FunctionDecl tmp1([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [s_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_partkey]
+        :
+        FieldAccessor [
+          Variable [ Name=p ]
+          Field=p_partkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [ps_supplycost]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=ps_supplycost
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_mfgr]
+        :
+        FieldAccessor [
+          Variable [ Name=p ]
+          Field=p_mfgr
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_address]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_phone]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_phone
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_comment]
+        :
+        FieldAccessor [
+          Variable [ Name=pssrn ]
+          Field=s_comment
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Part ]
+      AS
+      Variable [ Name=p ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_supplycost
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_address]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_comment
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=Partsupp ]
+          AS
+          Variable [ Name=ps ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_acctbal]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_acctbal
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_address]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_address
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_phone]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_phone
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_comment]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_comment
+                ]
+              )
+            ]
+            ]
+            FROM [              Variable [ Name=Supplier ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  Variable [ Name=Region ]
+                  AS
+                  Variable [ Name=r ]
+,
+                  Variable [ Name=Nation ]
+                  AS
+                  Variable [ Name=n ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=n ]
+                        Field=n_regionkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_regionkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_name
+                      ]
+                      =
+                      LiteralExpr [STRING] [EUROPE]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=rn ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=srn ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=pssrn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=pssrn ]
+            Field=p_partkey
+          ]
+        ]
+        and
+        FunctionCall tpch.like@2[
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_type
+          ]
+          LiteralExpr [STRING] [%BRASS]
+        ]
+      ]
+  )
+}
+
+FunctionDecl tmp2([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [p_partkey]
+        :
+        Variable [ Name=p_partkey ]
+      )
+      (
+        LiteralExpr [STRING] [ps_min_supplycost]
+        :
+        FunctionCall tpch.min@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=ps_supplycost
+            ]
+            ]
+            FROM [              Variable [ Name=pssrn ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Part ]
+      AS
+      Variable [ Name=p ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_supplycost
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_name]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_address]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_comment
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=Partsupp ]
+          AS
+          Variable [ Name=ps ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_acctbal]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_acctbal
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_address]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_address
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_phone]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_phone
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_comment]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_comment
+                ]
+              )
+            ]
+            ]
+            FROM [              Variable [ Name=Supplier ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  Variable [ Name=Region ]
+                  AS
+                  Variable [ Name=r ]
+,
+                  Variable [ Name=Nation ]
+                  AS
+                  Variable [ Name=n ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=n ]
+                        Field=n_regionkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_regionkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=r ]
+                        Field=r_name
+                      ]
+                      =
+                      LiteralExpr [STRING] [EUROPE]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=rn ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=rn ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=srn ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=srn ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=pssrn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=pssrn ]
+            Field=p_partkey
+          ]
+        ]
+        and
+        FunctionCall tpch.like@2[
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_type
+          ]
+          LiteralExpr [STRING] [%BRASS]
+        ]
+      ]
+    Groupby
+      Variable [ Name=p_partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=pssrn ]
+        Field=p_partkey
+      ]
+
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_acctbal]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_acctbal
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [p_partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=p_partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [p_mfgr]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=p_mfgr
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_address]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_address
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_phone]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_phone
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_comment]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=s_comment
+    ]
+  )
+]
+]
+FROM [  FunctionCall tpch.tmp2@0[
+  ]
+  AS
+  Variable [ Name=t2 ]
+,
+  FunctionCall tpch.tmp1@0[
+  ]
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=p_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=p_partkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=t1 ]
+        Field=ps_supplycost
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t2 ]
+        Field=ps_min_supplycost
+      ]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=s_acctbal
+  ]
+  DESC
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=n_name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=s_name
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=p_partkey
+  ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [100]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
new file mode 100644
index 0000000..8193892
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
@@ -0,0 +1,160 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_orderkey]
+    :
+    Variable [ Name=l_orderkey ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    Variable [ Name=o_orderdate ]
+  )
+  (
+    LiteralExpr [STRING] [o_shippriority]
+    :
+    Variable [ Name=o_shippriority ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_mktsegment
+        ]
+        =
+        LiteralExpr [STRING] [BUILDING]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+      ]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+        <
+        LiteralExpr [STRING] [1995-03-15]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipdate
+        ]
+        >
+        LiteralExpr [STRING] [1995-03-15]
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=l_orderkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_orderkey
+  ]
+  Variable [ Name=o_orderdate ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderdate
+  ]
+  Variable [ Name=o_shippriority ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_shippriority
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+  Variable [ Name=o_orderdate ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [10]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast
new file mode 100644
index 0000000..4dc7445
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast
@@ -0,0 +1,109 @@
+DataverseUse tpch
+FunctionDecl tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [o_orderkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_orderkey
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=LineItem ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_commitdate
+        ]
+        <
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_receiptdate
+        ]
+      ]
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [order_priority]
+    :
+    Variable [ Name=o_orderpriority ]
+  )
+  (
+    LiteralExpr [STRING] [count]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=o ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  FunctionCall tpch.tmp@0[
+  ]
+  AS
+  Variable [ Name=t ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=o_orderkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderdate
+      ]
+      >=
+      LiteralExpr [STRING] [1993-07-01]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderdate
+      ]
+      <
+      LiteralExpr [STRING] [1993-10-01]
+    ]
+  ]
+Groupby
+  Variable [ Name=o_orderpriority ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderpriority
+  ]
+  With
+  Variable [ Name=t ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=o_orderpriority ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
new file mode 100644
index 0000000..2b505fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
@@ -0,0 +1,344 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=l1 ]
+          Field=s_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_custkey
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=n1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_nationkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Supplier]
+              ]
+              AS
+              Variable [ Name=s ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_name
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_nationkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_nationkey
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Nation]
+                  ]
+                  AS
+                  Variable [ Name=n ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Region]
+                  ]
+                  AS
+                  Variable [ Name=r ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=n ]
+                      Field=n_regionkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=r ]
+                      Field=r_regionkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=n1 ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=n1 ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=s1 ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=s1 ]
+              Field=s_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l1 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l1 ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderdate
+          ]
+          >=
+          LiteralExpr [STRING] [1990-01-01]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_orderdate
+          ]
+          <
+          LiteralExpr [STRING] [1995-01-01]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=o1 ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=s_nationkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_custkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o1 ]
+        Field=o_custkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o1 ]
+    Field=n_name
+  ]
+  With
+  Variable [ Name=o1 ]
+  Variable [ Name=c ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=o1 ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
new file mode 100644
index 0000000..f802e5e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
@@ -0,0 +1,78 @@
+DataverseUse tpch
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_extendedprice
+          ]
+          *
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_discount
+          ]
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipdate
+              ]
+              >=
+              LiteralExpr [STRING] [1994-01-01]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipdate
+              ]
+              <
+              LiteralExpr [STRING] [1995-01-01]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_discount
+              ]
+              >=
+              LiteralExpr [DOUBLE] [0.05]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_discount
+              ]
+              <=
+              LiteralExpr [DOUBLE] [0.07]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <
+              LiteralExpr [LONG] [24]
+            ]
+          ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast
new file mode 100644
index 0000000..deed492
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast
@@ -0,0 +1,417 @@
+DataverseUse tpch
+FunctionDecl q7_volume_shipping_tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [supp_nation]
+        :
+        FieldAccessor [
+          Variable [ Name=n1 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [cust_nation]
+        :
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=n1 ]
+          Field=n_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_nationkey
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Nation ]
+      AS
+      Variable [ Name=n1 ]
+,
+      Variable [ Name=Nation ]
+      AS
+      Variable [ Name=n2 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=n2 ]
+            Field=n_name
+          ]
+          =
+          LiteralExpr [STRING] [GERMANY]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=n1 ]
+            Field=n_name
+          ]
+          =
+          LiteralExpr [STRING] [GERMANY]
+        ]
+      ]
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [supp_nation]
+    :
+    Variable [ Name=supp_nation ]
+  )
+  (
+    LiteralExpr [STRING] [cust_nation]
+    :
+    Variable [ Name=cust_nation ]
+  )
+  (
+    LiteralExpr [STRING] [l_year]
+    :
+    Variable [ Name=l_year ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_shipdate]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_shipdate
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_discount
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=c_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_nationkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_shipdate]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_shipdate
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=l_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [l_shipdate]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_shipdate
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_suppkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [o_custkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [LineItem]
+              ]
+              AS
+              Variable [ Name=l ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Orders]
+              ]
+              AS
+              Variable [ Name=o ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=o ]
+                    Field=o_orderkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_orderkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_shipdate
+                  ]
+                  >=
+                  LiteralExpr [STRING] [1992-01-01]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=l ]
+                    Field=l_shipdate
+                  ]
+                  <=
+                  LiteralExpr [STRING] [1996-12-31]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=lo ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=lo ]
+              Field=o_custkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=loc ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Supplier]
+      ]
+      AS
+      Variable [ Name=s ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_suppkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=loc ]
+          Field=l_suppkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=locs ]
+,
+  FunctionCall tpch.q7_volume_shipping_tmp@0[
+  ]
+  AS
+  Variable [ Name=t ]
+]
+LetVariable [ Name=l_year0 ]
+  :=
+  FunctionCall tpch.get-year@1[
+    FieldAccessor [
+      Variable [ Name=locs ]
+      Field=l_shipdate
+    ]
+  ]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=locs ]
+        Field=c_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=c_nationkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=locs ]
+        Field=s_nationkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=s_nationkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=supp_nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=supp_nation
+  ]
+  Variable [ Name=cust_nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=cust_nation
+  ]
+  Variable [ Name=l_year ]
+  :=
+  Variable [ Name=l_year0 ]
+  With
+  Variable [ Name=l_year0 ]
+  Variable [ Name=locs ]
+  Variable [ Name=t ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=locs ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=supp_nation ]
+  ASC
+  Variable [ Name=cust_nation ]
+  ASC
+  Variable [ Name=l_year ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.3.ast
new file mode 100644
index 0000000..f6dbd18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q08_national_market_share/q08_national_market_share.3.ast
@@ -0,0 +1,494 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [year]
+    :
+    Variable [ Name=year ]
+  )
+  (
+    LiteralExpr [STRING] [mkt_share]
+    :
+    OperatorExpr [
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FunctionCall tpch.switch-case@5[
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=s_name
+              ]
+              =
+              LiteralExpr [STRING] [BRAZIL]
+            ]
+            LiteralExpr [TRUE]
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=revenue
+            ]
+            LiteralExpr [FALSE]
+            LiteralExpr [DOUBLE] [0.0]
+          ]
+          ]
+          FROM [            Variable [ Name=t ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+      /
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=revenue
+          ]
+          ]
+          FROM [            Variable [ Name=t ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [year]
+        :
+        Variable [ Name=o_year ]
+      )
+      (
+        LiteralExpr [STRING] [revenue]
+        :
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=slnrcop ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=slnrcop ]
+              Field=l_discount
+            ]
+          ]
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_name
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [o_orderdate]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=o_orderdate
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [s_nationkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_nationkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Supplier]
+          ]
+          AS
+          Variable [ Name=s ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [o_orderdate]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=o_orderdate
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=lnrco ]
+                  Field=l_suppkey
+                ]
+              )
+            ]
+            ]
+            FROM [              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [o_orderdate]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=nrco ]
+                      Field=o_orderdate
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_partkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_partkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_discount]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_discount
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_extendedprice]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_extendedprice
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_suppkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [LineItem]
+                  ]
+                  AS
+                  Variable [ Name=l ]
+,
+                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [o_orderdate]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_orderdate
+                        ]
+                      )
+                      (
+                        LiteralExpr [STRING] [o_orderkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_orderkey
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Orders]
+                      ]
+                      AS
+                      Variable [ Name=o ]
+,
+                      (
+                        SELECT ELEMENT [
+                        RecordConstructor [
+                          (
+                            LiteralExpr [STRING] [c_custkey]
+                            :
+                            FieldAccessor [
+                              Variable [ Name=c ]
+                              Field=c_custkey
+                            ]
+                          )
+                        ]
+                        ]
+                        FROM [                          FunctionCall Metadata.dataset@1[
+                            LiteralExpr [STRING] [Customer]
+                          ]
+                          AS
+                          Variable [ Name=c ]
+,
+                          (
+                            SELECT ELEMENT [
+                            RecordConstructor [
+                              (
+                                LiteralExpr [STRING] [n_nationkey]
+                                :
+                                FieldAccessor [
+                                  Variable [ Name=n1 ]
+                                  Field=n_nationkey
+                                ]
+                              )
+                            ]
+                            ]
+                            FROM [                              FunctionCall Metadata.dataset@1[
+                                LiteralExpr [STRING] [Nation]
+                              ]
+                              AS
+                              Variable [ Name=n1 ]
+,
+                              FunctionCall Metadata.dataset@1[
+                                LiteralExpr [STRING] [Region]
+                              ]
+                              AS
+                              Variable [ Name=r1 ]
+                            ]
+                            Where
+                              OperatorExpr [
+                                OperatorExpr [
+                                  FieldAccessor [
+                                    Variable [ Name=n1 ]
+                                    Field=n_regionkey
+                                  ]
+                                  =
+                                  FieldAccessor [
+                                    Variable [ Name=r1 ]
+                                    Field=r_regionkey
+                                  ]
+                                ]
+                                and
+                                OperatorExpr [
+                                  FieldAccessor [
+                                    Variable [ Name=r1 ]
+                                    Field=r_name
+                                  ]
+                                  =
+                                  LiteralExpr [STRING] [AMERICA]
+                                ]
+                              ]
+                          )
+                          AS
+                          Variable [ Name=nr ]
+                        ]
+                        Where
+                          OperatorExpr [
+                            FieldAccessor [
+                              Variable [ Name=c ]
+                              Field=c_nationkey
+                            ]
+                            =
+                            FieldAccessor [
+                              Variable [ Name=nr ]
+                              Field=n_nationkey
+                            ]
+                          ]
+                      )
+                      AS
+                      Variable [ Name=nrc ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        FieldAccessor [
+                          Variable [ Name=nrc ]
+                          Field=c_custkey
+                        ]
+                        =
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_custkey
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=nrco ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=l ]
+                        Field=l_orderkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=nrco ]
+                        Field=o_orderkey
+                      ]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=nrco ]
+                        Field=o_orderdate
+                      ]
+                      >=
+                      LiteralExpr [STRING] [1995-01-01]
+                    ]
+                    and
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=nrco ]
+                        Field=o_orderdate
+                      ]
+                      <
+                      LiteralExpr [STRING] [1996-12-31]
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=lnrco ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Part]
+              ]
+              AS
+              Variable [ Name=p ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=p ]
+                    Field=p_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=lnrco ]
+                    Field=l_partkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=p ]
+                    Field=p_type
+                  ]
+                  =
+                  LiteralExpr [STRING] [ECONOMY ANODIZED STEEL]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=lnrcop ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_suppkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=lnrcop ]
+              Field=l_suppkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=slnrcop ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=n2 ]
+    ]
+    LetVariable [ Name=o_year ]
+      :=
+      FunctionCall tpch.get-year@1[
+        FieldAccessor [
+          Variable [ Name=slnrcop ]
+          Field=o_orderdate
+        ]
+      ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=slnrcop ]
+          Field=s_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=n2 ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t ]
+]
+Groupby
+  Variable [ Name=year ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t ]
+    Field=year
+  ]
+  With
+  Variable [ Name=t ]
+
+Orderby
+  Variable [ Name=year ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
new file mode 100644
index 0000000..8052433
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q09_product_type_profit_nt/q09_product_type_profit_nt.3.ast
@@ -0,0 +1,454 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation]
+    :
+    Variable [ Name=nation ]
+  )
+  (
+    LiteralExpr [STRING] [o_year]
+    :
+    Variable [ Name=o_year ]
+  )
+  (
+    LiteralExpr [STRING] [sum_profit]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=pr ]
+          Field=amount
+        ]
+        ]
+        FROM [          Variable [ Name=profit ]
+          AS
+          Variable [ Name=pr ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation]
+        :
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_year]
+        :
+        Variable [ Name=o_year ]
+      )
+      (
+        LiteralExpr [STRING] [amount]
+        :
+        Variable [ Name=amount ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_quantity]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_quantity
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=ps_supplycost
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Part]
+          ]
+          AS
+          Variable [ Name=p ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_quantity]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_quantity
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_partkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_partkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_orderkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_orderkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [ps_supplycost]
+                :
+                FieldAccessor [
+                  Variable [ Name=ps ]
+                  Field=ps_supplycost
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Partsupp]
+              ]
+              AS
+              Variable [ Name=ps ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [l_suppkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_extendedprice]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_extendedprice
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_discount]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_discount
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_quantity]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_quantity
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_partkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_partkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_orderkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_orderkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [s_suppkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_suppkey
+                        ]
+                      )
+                      (
+                        LiteralExpr [STRING] [n_name]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_name
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Supplier]
+                      ]
+                      AS
+                      Variable [ Name=s ]
+,
+                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Nation]
+                      ]
+                      AS
+                      Variable [ Name=n ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_nationkey
+                        ]
+                        =
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_nationkey
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=s1 ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [LineItem]
+                  ]
+                  AS
+                  Variable [ Name=l ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=s_suppkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=l1 ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_suppkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_suppkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_partkey
+                  ]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=l2 ]
+        ]
+        Where
+          OperatorExpr [
+            FunctionCall tpch.contains@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_name
+              ]
+              LiteralExpr [STRING] [green]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l2 ]
+                Field=l_partkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l3 ]
+    ]
+    LetVariable [ Name=amount ]
+      :=
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=l3 ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        -
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=ps_supplycost
+          ]
+          *
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_quantity
+          ]
+        ]
+      ]
+    LetVariable [ Name=o_year ]
+      :=
+      FunctionCall tpch.get-year@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+      ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=l_orderkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=profit ]
+]
+Groupby
+  Variable [ Name=nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=nation
+  ]
+  Variable [ Name=o_year ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=o_year
+  ]
+  With
+  Variable [ Name=profit ]
+
+Orderby
+  Variable [ Name=nation ]
+  ASC
+  Variable [ Name=o_year ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.3.ast
new file mode 100644
index 0000000..4f80066
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item/q10_returned_item.3.ast
@@ -0,0 +1,372 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [c_acctbal]
+    :
+    Variable [ Name=c_acctbal ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_address]
+    :
+    Variable [ Name=c_address ]
+  )
+  (
+    LiteralExpr [STRING] [c_phone]
+    :
+    Variable [ Name=c_phone ]
+  )
+  (
+    LiteralExpr [STRING] [c_comment]
+    :
+    Variable [ Name=c_comment ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_address]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_phone]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_phone
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_comment]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_comment
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_discount
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [c_custkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_name]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=n ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_address]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_comment
+            ]
+          )
+          (
+            LiteralExpr [STRING] [o_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_orderkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Nation]
+          ]
+          AS
+          Variable [ Name=n ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=c ]
+                  Field=c_custkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                >=
+                LiteralExpr [STRING] [1993-10-01]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                <
+                LiteralExpr [STRING] [1994-01-01]
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=c ]
+                Field=c_nationkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=n ]
+                Field=n_nationkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=ocn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ocn ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_returnflag
+          ]
+          =
+          LiteralExpr [STRING] [R]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=locn ]
+]
+Groupby
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_custkey
+  ]
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_name
+  ]
+  Variable [ Name=c_acctbal ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_acctbal
+  ]
+  Variable [ Name=c_phone ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_phone
+  ]
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=n_name
+  ]
+  Variable [ Name=c_address ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_address
+  ]
+  Variable [ Name=c_comment ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_comment
+  ]
+  With
+  Variable [ Name=locn ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=locn ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [20]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.3.ast
new file mode 100644
index 0000000..4f80066
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q10_returned_item_int64/q10_returned_item_int64.3.ast
@@ -0,0 +1,372 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [revenue]
+    :
+    Variable [ Name=revenue ]
+  )
+  (
+    LiteralExpr [STRING] [c_acctbal]
+    :
+    Variable [ Name=c_acctbal ]
+  )
+  (
+    LiteralExpr [STRING] [n_name]
+    :
+    Variable [ Name=n_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_address]
+    :
+    Variable [ Name=c_address ]
+  )
+  (
+    LiteralExpr [STRING] [c_phone]
+    :
+    Variable [ Name=c_phone ]
+  )
+  (
+    LiteralExpr [STRING] [c_comment]
+    :
+    Variable [ Name=c_comment ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_address]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_phone]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_phone
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_comment]
+        :
+        FieldAccessor [
+          Variable [ Name=ocn ]
+          Field=c_comment
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_extendedprice]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_extendedprice
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_discount]
+        :
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_discount
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [c_custkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_name]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_acctbal]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_acctbal
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=n ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_address]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_address
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_phone]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_phone
+            ]
+          )
+          (
+            LiteralExpr [STRING] [c_comment]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_comment
+            ]
+          )
+          (
+            LiteralExpr [STRING] [o_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_orderkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Nation]
+          ]
+          AS
+          Variable [ Name=n ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=c ]
+                  Field=c_custkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_custkey
+                ]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                >=
+                LiteralExpr [STRING] [1993-10-01]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderdate
+                ]
+                <
+                LiteralExpr [STRING] [1994-01-01]
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=c ]
+                Field=c_nationkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=n ]
+                Field=n_nationkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=ocn ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=ocn ]
+            Field=o_orderkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_returnflag
+          ]
+          =
+          LiteralExpr [STRING] [R]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=locn ]
+]
+Groupby
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_custkey
+  ]
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_name
+  ]
+  Variable [ Name=c_acctbal ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_acctbal
+  ]
+  Variable [ Name=c_phone ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_phone
+  ]
+  Variable [ Name=n_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=n_name
+  ]
+  Variable [ Name=c_address ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_address
+  ]
+  Variable [ Name=c_comment ]
+  :=
+  FieldAccessor [
+    Variable [ Name=locn ]
+    Field=c_comment
+  ]
+  With
+  Variable [ Name=locn ]
+
+LetVariable [ Name=revenue ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=locn ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=revenue ]
+  DESC
+
+Limit
+  LiteralExpr [LONG] [20]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.3.ast
new file mode 100644
index 0000000..6fb853e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q11_important_stock/q11_important_stock.3.ast
@@ -0,0 +1,230 @@
+DataverseUse tpch
+Query:
+LetVariable [ Name=sum ]
+  :=
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_supplycost
+        ]
+        *
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_availqty
+        ]
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Partsupp]
+        ]
+        AS
+        Variable [ Name=ps ]
+,
+        (
+          SELECT ELEMENT [
+          RecordConstructor [
+            (
+              LiteralExpr [STRING] [s_suppkey]
+              :
+              FieldAccessor [
+                Variable [ Name=s ]
+                Field=s_suppkey
+              ]
+            )
+          ]
+          ]
+          FROM [            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [Supplier]
+            ]
+            AS
+            Variable [ Name=s ]
+,
+            FunctionCall Metadata.dataset@1[
+              LiteralExpr [STRING] [Nation]
+            ]
+            AS
+            Variable [ Name=n ]
+          ]
+          Where
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=s ]
+                Field=s_nationkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=n ]
+                Field=n_nationkey
+              ]
+            ]
+        )
+        AS
+        Variable [ Name=sn ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=ps ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=sn ]
+            Field=s_suppkey
+          ]
+        ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [partkey]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=ps_partkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [part_value]
+    :
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=part_value
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [ps_partkey]
+        :
+        Variable [ Name=ps_partkey ]
+      )
+      (
+        LiteralExpr [STRING] [part_value]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=ps_supplycost
+              ]
+              *
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=ps_availqty
+              ]
+            ]
+            ]
+            FROM [              Variable [ Name=ps ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Partsupp]
+      ]
+      AS
+      Variable [ Name=ps ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [s_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Supplier]
+          ]
+          AS
+          Variable [ Name=s ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Nation]
+          ]
+          AS
+          Variable [ Name=n ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_nationkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=n ]
+              Field=n_nationkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=sn ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=ps ]
+          Field=ps_suppkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=sn ]
+          Field=s_suppkey
+        ]
+      ]
+    Groupby
+      Variable [ Name=ps_partkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=ps ]
+        Field=ps_partkey
+      ]
+      With
+      Variable [ Name=ps ]
+      Variable [ Name=sn ]
+      Variable [ Name=sum ]
+
+  )
+  AS
+  Variable [ Name=t1 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t1 ]
+      Field=part_value
+    ]
+    >
+    OperatorExpr [
+      Variable [ Name=sum ]
+      *
+      LiteralExpr [DOUBLE] [1.0E-5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t1 ]
+    Field=part_value
+  ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.3.ast
new file mode 100644
index 0000000..c478139
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q12_shipping/q12_shipping.3.ast
@@ -0,0 +1,192 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_shipmode]
+    :
+    Variable [ Name=l_shipmode ]
+  )
+  (
+    LiteralExpr [STRING] [high_line_count]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FunctionCall tpch.switch-case@5[
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [1-URGENT]
+            ]
+            or
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [2-HIGH]
+            ]
+          ]
+          LiteralExpr [TRUE]
+          LiteralExpr [LONG] [1]
+          LiteralExpr [FALSE]
+          LiteralExpr [LONG] [0]
+        ]
+        ]
+        FROM [          Variable [ Name=o ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [low_line_count]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FunctionCall tpch.switch-case@5[
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [1-URGENT]
+            ]
+            or
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=o_orderpriority
+              ]
+              =
+              LiteralExpr [STRING] [2-HIGH]
+            ]
+          ]
+          LiteralExpr [TRUE]
+          LiteralExpr [LONG] [0]
+          LiteralExpr [FALSE]
+          LiteralExpr [LONG] [1]
+        ]
+        ]
+        FROM [          Variable [ Name=o ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_commitdate
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_receiptdate
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_shipdate
+      ]
+      <
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_commitdate
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_receiptdate
+      ]
+      >=
+      LiteralExpr [STRING] [1994-01-01]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_receiptdate
+      ]
+      <
+      LiteralExpr [STRING] [1995-01-01]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipmode
+        ]
+        =
+        LiteralExpr [STRING] [MAIL]
+      ]
+      or
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_shipmode
+        ]
+        =
+        LiteralExpr [STRING] [SHIP]
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=l_shipmode ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_shipmode
+  ]
+  With
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=l_shipmode ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.3.ast
new file mode 100644
index 0000000..2b22632
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q13_customer_distribution/q13_customer_distribution.3.ast
@@ -0,0 +1,147 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_count]
+    :
+    Variable [ Name=c_count ]
+  )
+  (
+    LiteralExpr [STRING] [custdist]
+    :
+    Variable [ Name=custdist ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        Variable [ Name=c_custkey ]
+      )
+      (
+        LiteralExpr [STRING] [c_count]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=o_orderkey_count
+            ]
+            ]
+            FROM [              Variable [ Name=co ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [c_custkey]
+            :
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_custkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [o_orderkey_count]
+            :
+            FunctionCall tpch.count@1[
+              (
+                SELECT ELEMENT [
+                FieldAccessor [
+                  Variable [ Name=o ]
+                  Field=o_orderkey
+                ]
+                ]
+                FROM [                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [Orders]
+                  ]
+                  AS
+                  Variable [ Name=o ]
+                ]
+                Where
+                  OperatorExpr [
+                    OperatorExpr [
+                      FieldAccessor [
+                        Variable [ Name=c ]
+                        Field=c_custkey
+                      ]
+                      =
+                      FieldAccessor [
+                        Variable [ Name=o ]
+                        Field=o_custkey
+                      ]
+                    ]
+                    and
+                    FunctionCall tpch.not@1[
+                      FunctionCall tpch.like@2[
+                        FieldAccessor [
+                          Variable [ Name=o ]
+                          Field=o_comment
+                        ]
+                        LiteralExpr [STRING] [%special%requests%]
+                      ]
+                    ]
+                  ]
+              )
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Customer]
+          ]
+          AS
+          Variable [ Name=c ]
+        ]
+      )
+      AS
+      Variable [ Name=co ]
+    ]
+    Groupby
+      Variable [ Name=c_custkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=co ]
+        Field=c_custkey
+      ]
+      With
+      Variable [ Name=co ]
+
+  )
+  AS
+  Variable [ Name=gco ]
+]
+Groupby
+  Variable [ Name=c_count ]
+  :=
+  FieldAccessor [
+    Variable [ Name=gco ]
+    Field=c_count
+  ]
+  With
+  Variable [ Name=gco ]
+
+LetVariable [ Name=custdist ]
+  :=
+  FunctionCall tpch.count@1[
+    Variable [ Name=gco ]
+  ]
+Orderby
+  Variable [ Name=custdist ]
+  DESC
+  Variable [ Name=c_count ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.3.ast
new file mode 100644
index 0000000..57b4c73
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q14_promotion_effect/q14_promotion_effect.3.ast
@@ -0,0 +1,123 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+OperatorExpr [
+  LiteralExpr [DOUBLE] [100.0]
+  *
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      FunctionCall tpch.switch-case@5[
+        FunctionCall tpch.like@2[
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=p_type
+          ]
+          LiteralExpr [STRING] [PROMO%]
+        ]
+        LiteralExpr [TRUE]
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        LiteralExpr [FALSE]
+        LiteralExpr [DOUBLE] [0.0]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+  /
+  FunctionCall tpch.sum@1[
+    (
+      SELECT ELEMENT [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        *
+        OperatorExpr [
+          LiteralExpr [LONG] [1]
+          -
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_discount
+          ]
+        ]
+      ]
+      ]
+      FROM [        Variable [ Name=l ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Part]
+  ]
+  AS
+  Variable [ Name=p ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_partkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=p ]
+        Field=p_partkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_shipdate
+      ]
+      >=
+      LiteralExpr [STRING] [1995-09-01]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_shipdate
+      ]
+      <
+      LiteralExpr [STRING] [1995-10-01]
+    ]
+  ]
+Groupby
+  Variable [ Name=t ]
+  :=
+  LiteralExpr [LONG] [1]
+  With
+  Variable [ Name=p ]
+  Variable [ Name=l ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.3.ast
new file mode 100644
index 0000000..b19616d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q15_top_supplier/q15_top_supplier.3.ast
@@ -0,0 +1,189 @@
+DataverseUse tpch
+FunctionDecl revenue([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [supplier_no]
+        :
+        Variable [ Name=l_suppkey ]
+      )
+      (
+        LiteralExpr [STRING] [total_revenue]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=i ]
+                Field=l_extendedprice
+              ]
+              *
+              OperatorExpr [
+                LiteralExpr [LONG] [1]
+                -
+                FieldAccessor [
+                  Variable [ Name=i ]
+                  Field=l_discount
+                ]
+              ]
+            ]
+            ]
+            FROM [              Variable [ Name=l ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=LineItem ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_shipdate
+          ]
+          >=
+          LiteralExpr [STRING] [1996-01-01]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_shipdate
+          ]
+          <
+          LiteralExpr [STRING] [1996-04-01]
+        ]
+      ]
+    Groupby
+      Variable [ Name=l_suppkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_suppkey
+      ]
+
+  )
+}
+
+Query:
+LetVariable [ Name=m ]
+  :=
+  FunctionCall tpch.max@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=r2 ]
+        Field=total_revenue
+      ]
+      ]
+      FROM [        FunctionCall tpch.revenue@0[
+        ]
+        AS
+        Variable [ Name=r2 ]
+      ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_suppkey]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_suppkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_address]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_address
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_phone]
+    :
+    FieldAccessor [
+      Variable [ Name=s ]
+      Field=s_phone
+    ]
+  )
+  (
+    LiteralExpr [STRING] [total_revenue]
+    :
+    FieldAccessor [
+      Variable [ Name=r ]
+      Field=total_revenue
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Supplier]
+  ]
+  AS
+  Variable [ Name=s ]
+,
+  FunctionCall tpch.revenue@0[
+  ]
+  AS
+  Variable [ Name=r ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=s ]
+        Field=s_suppkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=supplier_no
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=total_revenue
+      ]
+      <
+      OperatorExpr [
+        Variable [ Name=m ]
+        +
+        LiteralExpr [DOUBLE] [1.0E-9]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=r ]
+        Field=total_revenue
+      ]
+      >
+      OperatorExpr [
+        Variable [ Name=m ]
+        -
+        LiteralExpr [DOUBLE] [1.0E-9]
+      ]
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
new file mode 100644
index 0000000..dc55293
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q16_parts_supplier_relationship/q16_parts_supplier_relationship.3.ast
@@ -0,0 +1,361 @@
+DataverseUse tpch
+FunctionDecl tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [p_brand]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=p_brand
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_type]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=p_type
+        ]
+      )
+      (
+        LiteralExpr [STRING] [p_size]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=p_size
+        ]
+      )
+      (
+        LiteralExpr [STRING] [ps_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=psp ]
+          Field=ps_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [p_brand]
+            :
+            FieldAccessor [
+              Variable [ Name=p ]
+              Field=p_brand
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_type]
+            :
+            FieldAccessor [
+              Variable [ Name=p ]
+              Field=p_type
+            ]
+          )
+          (
+            LiteralExpr [STRING] [p_size]
+            :
+            FieldAccessor [
+              Variable [ Name=p ]
+              Field=p_size
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=Partsupp ]
+          AS
+          Variable [ Name=ps ]
+,
+          Variable [ Name=Part ]
+          AS
+          Variable [ Name=p ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=ps ]
+                Field=ps_partkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              !=
+              LiteralExpr [STRING] [Brand#45]
+            ]
+            and
+            FunctionCall tpch.not@1[
+              FunctionCall tpch.like@2[
+                FieldAccessor [
+                  Variable [ Name=p ]
+                  Field=p_type
+                ]
+                LiteralExpr [STRING] [MEDIUM POLISHED%]
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=psp ]
+,
+      Variable [ Name=Supplier ]
+      AS
+      Variable [ Name=s ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=psp ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=s ]
+            Field=s_suppkey
+          ]
+        ]
+        and
+        FunctionCall tpch.not@1[
+          FunctionCall tpch.like@2[
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=s_comment
+            ]
+            LiteralExpr [STRING] [%Customer%Complaints%]
+          ]
+        ]
+      ]
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [p_brand]
+    :
+    Variable [ Name=p_brand ]
+  )
+  (
+    LiteralExpr [STRING] [p_type]
+    :
+    Variable [ Name=p_type ]
+  )
+  (
+    LiteralExpr [STRING] [p_size]
+    :
+    Variable [ Name=p_size ]
+  )
+  (
+    LiteralExpr [STRING] [supplier_cnt]
+    :
+    Variable [ Name=supplier_cnt ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [p_brand]
+        :
+        Variable [ Name=p_brand1 ]
+      )
+      (
+        LiteralExpr [STRING] [p_type]
+        :
+        Variable [ Name=p_type1 ]
+      )
+      (
+        LiteralExpr [STRING] [p_size]
+        :
+        Variable [ Name=p_size1 ]
+      )
+      (
+        LiteralExpr [STRING] [ps_suppkey]
+        :
+        Variable [ Name=ps_suppkey1 ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall tpch.tmp@0[
+      ]
+      AS
+      Variable [ Name=t ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [49]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [14]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [23]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [45]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [19]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [3]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [36]
+        ]
+        or
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t ]
+            Field=p_size
+          ]
+          =
+          LiteralExpr [LONG] [9]
+        ]
+      ]
+    Groupby
+      Variable [ Name=p_brand1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=p_brand
+      ]
+      Variable [ Name=p_type1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=p_type
+      ]
+      Variable [ Name=p_size1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=p_size
+      ]
+      Variable [ Name=ps_suppkey1 ]
+      :=
+      FieldAccessor [
+        Variable [ Name=t ]
+        Field=ps_suppkey
+      ]
+      With
+      Variable [ Name=t ]
+
+  )
+  AS
+  Variable [ Name=t2 ]
+]
+Groupby
+  Variable [ Name=p_brand ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t2 ]
+    Field=p_brand
+  ]
+  Variable [ Name=p_type ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t2 ]
+    Field=p_type
+  ]
+  Variable [ Name=p_size ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t2 ]
+    Field=p_size
+  ]
+  With
+  Variable [ Name=t2 ]
+
+LetVariable [ Name=supplier_cnt ]
+  :=
+  FunctionCall tpch.count@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=ps_suppkey
+      ]
+      ]
+      FROM [        Variable [ Name=t2 ]
+        AS
+        Variable [ Name=i ]
+      ]
+    )
+  ]
+Orderby
+  Variable [ Name=supplier_cnt ]
+  DESC
+  Variable [ Name=p_brand ]
+  ASC
+  Variable [ Name=p_type ]
+  ASC
+  Variable [ Name=p_size ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.3.ast
new file mode 100644
index 0000000..19e5d78
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q17_large_gby_variant/q17_large_gby_variant.3.ast
@@ -0,0 +1,222 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [t_partkey]
+    :
+    Variable [ Name=l_partkey ]
+  )
+  (
+    LiteralExpr [STRING] [t_count]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_quantity]
+    :
+    OperatorExpr [
+      LiteralExpr [DOUBLE] [0.2]
+      *
+      FunctionCall tpch.avg@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_quantity
+          ]
+          ]
+          FROM [            Variable [ Name=l ]
+            AS
+            Variable [ Name=i ]
+          ]
+        )
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_suppkey]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_suppkey
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_linenumber]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_linenumber
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_extendedprice]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_discount]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_avg_tax]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_tax
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_shipdate]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_shipdate
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_min_commitdate]
+    :
+    FunctionCall tpch.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_commitdate
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_min_receiptdate]
+    :
+    FunctionCall tpch.min@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_receiptdate
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [t_max_comment]
+    :
+    FunctionCall tpch.max@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_comment
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Groupby
+  Variable [ Name=l_partkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_partkey
+  ]
+  With
+  Variable [ Name=l ]
+
+Orderby
+  Variable [ Name=l_partkey ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.3.ast
new file mode 100644
index 0000000..edf6190
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q18_large_volume_customer/q18_large_volume_customer.3.ast
@@ -0,0 +1,211 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [c_name]
+    :
+    Variable [ Name=c_name ]
+  )
+  (
+    LiteralExpr [STRING] [c_custkey]
+    :
+    Variable [ Name=c_custkey ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderkey]
+    :
+    Variable [ Name=o_orderkey ]
+  )
+  (
+    LiteralExpr [STRING] [o_orderdate]
+    :
+    Variable [ Name=o_orderdate ]
+  )
+  (
+    LiteralExpr [STRING] [o_totalprice]
+    :
+    Variable [ Name=o_totalprice ]
+  )
+  (
+    LiteralExpr [STRING] [sum_quantity]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=j ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          Variable [ Name=l ]
+          AS
+          Variable [ Name=j ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Customer]
+  ]
+  AS
+  Variable [ Name=c ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Orders]
+  ]
+  AS
+  Variable [ Name=o ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [t_sum_quantity]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_quantity
+            ]
+            ]
+            FROM [              Variable [ Name=l ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      With
+      Variable [ Name=l ]
+      Variable [ Name=c ]
+      Variable [ Name=o ]
+
+  )
+  AS
+  Variable [ Name=t ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_custkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_custkey
+      ]
+    ]
+    and
+    OperatorExpr [
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=l_orderkey
+        ]
+      ]
+      and
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=t ]
+          Field=t_sum_quantity
+        ]
+        >
+        LiteralExpr [LONG] [30]
+      ]
+    ]
+    and
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_orderkey
+      ]
+      =
+      FieldAccessor [
+        Variable [ Name=o ]
+        Field=o_orderkey
+      ]
+    ]
+  ]
+Groupby
+  Variable [ Name=c_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_name
+  ]
+  Variable [ Name=c_custkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=c ]
+    Field=c_custkey
+  ]
+  Variable [ Name=o_orderkey ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderkey
+  ]
+  Variable [ Name=o_orderdate ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_orderdate
+  ]
+  Variable [ Name=o_totalprice ]
+  :=
+  FieldAccessor [
+    Variable [ Name=o ]
+    Field=o_totalprice
+  ]
+  With
+  Variable [ Name=c ]
+  Variable [ Name=t ]
+  Variable [ Name=l ]
+  Variable [ Name=o ]
+
+Orderby
+  Variable [ Name=o_totalprice ]
+  DESC
+  Variable [ Name=o_orderdate ]
+  ASC
+
+Limit
+  LiteralExpr [LONG] [100]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.3.ast
new file mode 100644
index 0000000..46e01a7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q19_discounted_revenue/q19_discounted_revenue.3.ast
@@ -0,0 +1,270 @@
+DataverseUse tpch
+Set import-private-functions=true
+Query:
+SELECT ELEMENT [
+FunctionCall tpch.sum@1[
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=l ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_discount
+        ]
+      ]
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [LineItem]
+      ]
+      AS
+      Variable [ Name=l ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Part]
+      ]
+      AS
+      Variable [ Name=p ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=p ]
+            Field=p_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              =
+              LiteralExpr [STRING] [Brand#12]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              LiteralExpr [STRING] [SM CASE||SM BOX||SM PACK||SM PKG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <=
+              LiteralExpr [LONG] [11]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              <=
+              LiteralExpr [LONG] [5]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipmode
+              ]
+              LiteralExpr [STRING] [AIR||AIR REG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipinstruct
+              ]
+              =
+              LiteralExpr [STRING] [DELIVER IN PERSON]
+            ]
+          ]
+          or
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              =
+              LiteralExpr [STRING] [Brand#23]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              LiteralExpr [STRING] [MED BAG||MED BOX||MED PKG||MED PACK]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              >=
+              LiteralExpr [LONG] [10]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <=
+              LiteralExpr [LONG] [20]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              <=
+              LiteralExpr [LONG] [10]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipmode
+              ]
+              LiteralExpr [STRING] [AIR||AIR REG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipinstruct
+              ]
+              =
+              LiteralExpr [STRING] [DELIVER IN PERSON]
+            ]
+          ]
+          or
+          OperatorExpr [
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_brand
+              ]
+              =
+              LiteralExpr [STRING] [Brand#34]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_container
+              ]
+              LiteralExpr [STRING] [LG CASE||LG BOX||LG PACK||LG PKG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              >=
+              LiteralExpr [LONG] [20]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_quantity
+              ]
+              <=
+              LiteralExpr [LONG] [30]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              >=
+              LiteralExpr [LONG] [1]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_size
+              ]
+              <=
+              LiteralExpr [LONG] [15]
+            ]
+            and
+            FunctionCall tpch.reg-exp@2[
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipmode
+              ]
+              LiteralExpr [STRING] [AIR||AIR REG]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_shipinstruct
+              ]
+              =
+              LiteralExpr [STRING] [DELIVER IN PERSON]
+            ]
+          ]
+        ]
+      ]
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
new file mode 100644
index 0000000..fda99ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q20_potential_part_promotion/q20_potential_part_promotion.3.ast
@@ -0,0 +1,290 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    FieldAccessor [
+      Variable [ Name=t4 ]
+      Field=s_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [s_address]
+    :
+    FieldAccessor [
+      Variable [ Name=t4 ]
+      Field=s_address
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [ps_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=pst1 ]
+          Field=ps_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_partkey]
+            :
+            Variable [ Name=l_partkey ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            Variable [ Name=l_suppkey ]
+          )
+          (
+            LiteralExpr [STRING] [sum_quantity]
+            :
+            OperatorExpr [
+              LiteralExpr [DOUBLE] [0.5]
+              *
+              FunctionCall tpch.sum@1[
+                (
+                  SELECT ELEMENT [
+                  FieldAccessor [
+                    Variable [ Name=i ]
+                    Field=l_quantity
+                  ]
+                  ]
+                  FROM [                    Variable [ Name=l ]
+                    AS
+                    Variable [ Name=i ]
+                  ]
+                )
+              ]
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Groupby
+          Variable [ Name=l_partkey ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_partkey
+          ]
+          Variable [ Name=l_suppkey ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_suppkey
+          ]
+          With
+          Variable [ Name=l ]
+
+      )
+      AS
+      Variable [ Name=t2 ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [ps_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_suppkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_partkey]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_availqty]
+            :
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_availqty
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Partsupp]
+          ]
+          AS
+          Variable [ Name=ps ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [p_partkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=p ]
+                  Field=p_partkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Part]
+              ]
+              AS
+              Variable [ Name=p ]
+            ]
+          )
+          AS
+          Variable [ Name=t1 ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=ps ]
+              Field=ps_partkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=p_partkey
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=pst1 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=pst1 ]
+            Field=ps_partkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=l_partkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=pst1 ]
+            Field=ps_suppkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=l_suppkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=pst1 ]
+            Field=ps_availqty
+          ]
+          >
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=sum_quantity
+          ]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t3 ]
+,
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_address]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_address
+        ]
+      )
+      (
+        LiteralExpr [STRING] [s_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Supplier]
+      ]
+      AS
+      Variable [ Name=s ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=s ]
+          Field=s_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=n ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t4 ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=t3 ]
+      Field=ps_suppkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=t4 ]
+      Field=s_suppkey
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=t4 ]
+    Field=s_name
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ast
new file mode 100644
index 0000000..bf537c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : int64,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int64,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int64,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int64,
+    ps_suppkey : int64,
+    ps_availqty : int64,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
new file mode 100644
index 0000000..c471683
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q21_suppliers_who_kept_orders_waiting/q21_suppliers_who_kept_orders_waiting.3.ast
@@ -0,0 +1,467 @@
+DataverseUse tpch
+FunctionDecl tmp1([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [count_suppkey]
+        :
+        FunctionCall tpch.count@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+      (
+        LiteralExpr [STRING] [max_suppkey]
+        :
+        FunctionCall tpch.max@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            Variable [ Name=l_orderkey1 ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            Variable [ Name=l_suppkey1 ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=LineItem ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Groupby
+          Variable [ Name=l_orderkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          Variable [ Name=l_suppkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_suppkey
+          ]
+
+      )
+      AS
+      Variable [ Name=l2 ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l2 ]
+        Field=l_orderkey
+      ]
+
+  )
+}
+
+FunctionDecl tmp2([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        Variable [ Name=l_orderkey ]
+      )
+      (
+        LiteralExpr [STRING] [count_suppkey]
+        :
+        FunctionCall tpch.count@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+      (
+        LiteralExpr [STRING] [max_suppkey]
+        :
+        FunctionCall tpch.max@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_suppkey
+            ]
+            ]
+            FROM [              Variable [ Name=l2 ]
+              AS
+              Variable [ Name=i ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            Variable [ Name=l_orderkey1 ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            Variable [ Name=l_suppkey1 ]
+          )
+        ]
+        ]
+        FROM [          Variable [ Name=LineItem ]
+          AS
+          Variable [ Name=l ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_receiptdate
+            ]
+            >
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_commitdate
+            ]
+          ]
+        Groupby
+          Variable [ Name=l_orderkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_orderkey
+          ]
+          Variable [ Name=l_suppkey1 ]
+          :=
+          FieldAccessor [
+            Variable [ Name=l ]
+            Field=l_suppkey
+          ]
+
+      )
+      AS
+      Variable [ Name=l2 ]
+    ]
+    Groupby
+      Variable [ Name=l_orderkey ]
+      :=
+      FieldAccessor [
+        Variable [ Name=l2 ]
+        Field=l_orderkey
+      ]
+
+  )
+}
+
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [s_name]
+    :
+    Variable [ Name=s_name ]
+  )
+  (
+    LiteralExpr [STRING] [numwait]
+    :
+    Variable [ Name=numwait ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [s_name]
+        :
+        FieldAccessor [
+          Variable [ Name=t3 ]
+          Field=s_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t3 ]
+          Field=l_suppkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [l_orderkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=l_orderkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [count_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=count_suppkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [max_suppkey]
+        :
+        FieldAccessor [
+          Variable [ Name=t2 ]
+          Field=max_suppkey
+        ]
+      )
+    ]
+    ]
+    FROM [      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [s_name]
+            :
+            FieldAccessor [
+              Variable [ Name=ns ]
+              Field=s_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=t1 ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_suppkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_suppkey
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [s_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [s_suppkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_suppkey
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Nation]
+              ]
+              AS
+              Variable [ Name=n ]
+,
+              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Supplier]
+              ]
+              AS
+              Variable [ Name=s ]
+            ]
+            Where
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=s ]
+                  Field=s_nationkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=n ]
+                  Field=n_nationkey
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=ns ]
+,
+          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+,
+          FunctionCall tpch.tmp1@0[
+          ]
+          AS
+          Variable [ Name=t1 ]
+        ]
+        Where
+          OperatorExpr [
+            OperatorExpr [
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=ns ]
+                  Field=s_suppkey
+                ]
+                =
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_suppkey
+                ]
+              ]
+              and
+              OperatorExpr [
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_receiptdate
+                ]
+                >
+                FieldAccessor [
+                  Variable [ Name=l ]
+                  Field=l_commitdate
+                ]
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=o ]
+                Field=o_orderkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_orderkey
+              ]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=l ]
+                Field=l_orderkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=t1 ]
+                Field=l_orderkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=t3 ]
+,
+      FunctionCall tpch.tmp2@0[
+      ]
+      AS
+      Variable [ Name=t2 ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=count_suppkey
+          ]
+          >=
+          LiteralExpr [LONG] [0]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=t3 ]
+            Field=l_orderkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=t2 ]
+            Field=l_orderkey
+          ]
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=t4 ]
+]
+Groupby
+  Variable [ Name=s_name ]
+  :=
+  FieldAccessor [
+    Variable [ Name=t4 ]
+    Field=s_name
+  ]
+  With
+  Variable [ Name=t4 ]
+
+LetVariable [ Name=numwait ]
+  :=
+  FunctionCall tpch.count@1[
+    Variable [ Name=t4 ]
+  ]
+Orderby
+  Variable [ Name=numwait ]
+  DESC
+  Variable [ Name=s_name ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
new file mode 100644
index 0000000..8efbfe5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast
@@ -0,0 +1,133 @@
+DataverseUse tpch
+FunctionDecl q22_customer_tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [cntrycode]
+        :
+        FunctionCall tpch.substring@3[
+          FieldAccessor [
+            Variable [ Name=c ]
+            Field=c_phone
+          ]
+          LiteralExpr [LONG] [1]
+          LiteralExpr [LONG] [2]
+        ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Customer ]
+      AS
+      Variable [ Name=c ]
+    ]
+  )
+}
+
+Query:
+LetVariable [ Name=avg ]
+  :=
+  FunctionCall tpch.avg@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_acctbal
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=c ]
+      ]
+      Where
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=c ]
+            Field=c_acctbal
+          ]
+          >
+          LiteralExpr [DOUBLE] [0.0]
+        ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cntrycode]
+    :
+    Variable [ Name=cntrycode ]
+  )
+  (
+    LiteralExpr [STRING] [numcust]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=ct ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [totacctbal]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=c_acctbal
+        ]
+        ]
+        FROM [          Variable [ Name=ct ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall tpch.q22_customer_tmp@0[
+  ]
+  AS
+  Variable [ Name=ct ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=ct ]
+      Field=c_acctbal
+    ]
+    >
+    Variable [ Name=avg ]
+  ]
+Groupby
+  Variable [ Name=cntrycode ]
+  :=
+  FieldAccessor [
+    Variable [ Name=ct ]
+    Field=cntrycode
+  ]
+  With
+  Variable [ Name=ct ]
+  Variable [ Name=avg ]
+
+Orderby
+  Variable [ Name=cntrycode ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.1.ast
new file mode 100644
index 0000000..c3efb40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Part(PartType) partitioned by [[p_partkey]]
+DatasetDecl Partsupp(PartSuppType) partitioned by [[ps_partkey], [ps_suppkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast
new file mode 100644
index 0000000..a596782
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast
@@ -0,0 +1,257 @@
+DataverseUse tpch
+FunctionDecl q22_customer_tmp([]) {
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [c_acctbal]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_acctbal
+        ]
+      )
+      (
+        LiteralExpr [STRING] [c_custkey]
+        :
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_custkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [cntrycode]
+        :
+        Variable [ Name=phone_substr ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=Customer ]
+      AS
+      Variable [ Name=c ]
+    ]
+    LetVariable [ Name=phone_substr ]
+      :=
+      FunctionCall tpch.substring@3[
+        FieldAccessor [
+          Variable [ Name=c ]
+          Field=c_phone
+        ]
+        LiteralExpr [LONG] [1]
+        LiteralExpr [LONG] [2]
+      ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [13]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [31]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [23]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [29]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [30]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [18]
+        ]
+        or
+        OperatorExpr [
+          Variable [ Name=phone_substr ]
+          =
+          LiteralExpr [STRING] [17]
+        ]
+      ]
+  )
+}
+
+Query:
+LetVariable [ Name=avg ]
+  :=
+  FunctionCall tpch.avg@1[
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=c ]
+        Field=c_acctbal
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=c ]
+      ]
+      LetVariable [ Name=phone_substr ]
+        :=
+        FunctionCall tpch.substring@3[
+          FieldAccessor [
+            Variable [ Name=c ]
+            Field=c_phone
+          ]
+          LiteralExpr [LONG] [1]
+          LiteralExpr [LONG] [2]
+        ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=c ]
+              Field=c_acctbal
+            ]
+            >
+            LiteralExpr [DOUBLE] [0.0]
+          ]
+          and
+          OperatorExpr [
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [13]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [31]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [23]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [29]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [30]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [18]
+            ]
+            or
+            OperatorExpr [
+              Variable [ Name=phone_substr ]
+              =
+              LiteralExpr [STRING] [17]
+            ]
+          ]
+        ]
+    )
+  ]
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [cntrycode]
+    :
+    Variable [ Name=cntrycode ]
+  )
+  (
+    LiteralExpr [STRING] [numcust]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=ct ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [totacctbal]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=c_acctbal
+        ]
+        ]
+        FROM [          Variable [ Name=ct ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  FunctionCall tpch.q22_customer_tmp@0[
+  ]
+  AS
+  Variable [ Name=ct ]
+]
+Where
+  OperatorExpr [
+    FunctionCall tpch.count@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=o ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Orders]
+          ]
+          AS
+          Variable [ Name=o ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=ct ]
+              Field=c_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_custkey
+            ]
+          ]
+      )
+    ]
+    =
+    LiteralExpr [LONG] [0]
+  ]
+Groupby
+  Variable [ Name=cntrycode ]
+  :=
+  FieldAccessor [
+    Variable [ Name=ct ]
+    Field=cntrycode
+  ]
+  With
+  Variable [ Name=ct ]
+  Variable [ Name=avg ]
+
+Orderby
+  Variable [ Name=cntrycode ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.1.ast
new file mode 100644
index 0000000..3535ea2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int64,
+    l_partkey : int64,
+    l_suppkey : int64,
+    l_linenumber : int64,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.3.ast
new file mode 100644
index 0000000..3776535
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue601/query-issue601.3.ast
@@ -0,0 +1,34 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_linenumber]
+    :
+    Variable [ Name=l_linenumber ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=l ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Groupby
+  Variable [ Name=l_linenumber ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linenumber
+  ]
+  With
+  Variable [ Name=l ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.1.ast
new file mode 100644
index 0000000..12dce1c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.1.ast
@@ -0,0 +1,102 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : int32,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+TypeDecl PartType [
+  closed RecordType {
+    p_partkey : int32,
+    p_name : string,
+    p_mfgr : string,
+    p_brand : string,
+    p_type : string,
+    p_size : int32,
+    p_container : string,
+    p_retailprice : double,
+    p_comment : string
+  }
+]
+TypeDecl PartSuppType [
+  closed RecordType {
+    ps_partkey : int32,
+    ps_suppkey : int32,
+    ps_availqty : int32,
+    ps_supplycost : double,
+    ps_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType)is an external dataset
+DatasetDecl Orders(OrderType)is an external dataset
+DatasetDecl Supplier(SupplierType)is an external dataset
+DatasetDecl Region(RegionType)is an external dataset
+DatasetDecl Nation(NationType)is an external dataset
+DatasetDecl Part(PartType)is an external dataset
+DatasetDecl Partsupp(PartSuppType)is an external dataset
+DatasetDecl Customer(CustomerType)is an external dataset
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.3.ast
new file mode 100644
index 0000000..8052433
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue638/query-issue638.3.ast
@@ -0,0 +1,454 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation]
+    :
+    Variable [ Name=nation ]
+  )
+  (
+    LiteralExpr [STRING] [o_year]
+    :
+    Variable [ Name=o_year ]
+  )
+  (
+    LiteralExpr [STRING] [sum_profit]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=pr ]
+          Field=amount
+        ]
+        ]
+        FROM [          Variable [ Name=profit ]
+          AS
+          Variable [ Name=pr ]
+        ]
+      )
+    ]
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation]
+        :
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=n_name
+        ]
+      )
+      (
+        LiteralExpr [STRING] [o_year]
+        :
+        Variable [ Name=o_year ]
+      )
+      (
+        LiteralExpr [STRING] [amount]
+        :
+        Variable [ Name=amount ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=o ]
+,
+      (
+        SELECT ELEMENT [
+        RecordConstructor [
+          (
+            LiteralExpr [STRING] [l_extendedprice]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_extendedprice
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_discount]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_discount
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_quantity]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_quantity
+            ]
+          )
+          (
+            LiteralExpr [STRING] [l_orderkey]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=l_orderkey
+            ]
+          )
+          (
+            LiteralExpr [STRING] [n_name]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=n_name
+            ]
+          )
+          (
+            LiteralExpr [STRING] [ps_supplycost]
+            :
+            FieldAccessor [
+              Variable [ Name=l2 ]
+              Field=ps_supplycost
+            ]
+          )
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [Part]
+          ]
+          AS
+          Variable [ Name=p ]
+,
+          (
+            SELECT ELEMENT [
+            RecordConstructor [
+              (
+                LiteralExpr [STRING] [l_extendedprice]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_extendedprice
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_discount]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_discount
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_quantity]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_quantity
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_partkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_partkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [l_orderkey]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=l_orderkey
+                ]
+              )
+              (
+                LiteralExpr [STRING] [n_name]
+                :
+                FieldAccessor [
+                  Variable [ Name=l1 ]
+                  Field=n_name
+                ]
+              )
+              (
+                LiteralExpr [STRING] [ps_supplycost]
+                :
+                FieldAccessor [
+                  Variable [ Name=ps ]
+                  Field=ps_supplycost
+                ]
+              )
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [Partsupp]
+              ]
+              AS
+              Variable [ Name=ps ]
+,
+              (
+                SELECT ELEMENT [
+                RecordConstructor [
+                  (
+                    LiteralExpr [STRING] [l_suppkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_extendedprice]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_extendedprice
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_discount]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_discount
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_quantity]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_quantity
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_partkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_partkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [l_orderkey]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_orderkey
+                    ]
+                  )
+                  (
+                    LiteralExpr [STRING] [n_name]
+                    :
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=n_name
+                    ]
+                  )
+                ]
+                ]
+                FROM [                  (
+                    SELECT ELEMENT [
+                    RecordConstructor [
+                      (
+                        LiteralExpr [STRING] [s_suppkey]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_suppkey
+                        ]
+                      )
+                      (
+                        LiteralExpr [STRING] [n_name]
+                        :
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_name
+                        ]
+                      )
+                    ]
+                    ]
+                    FROM [                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Supplier]
+                      ]
+                      AS
+                      Variable [ Name=s ]
+,
+                      FunctionCall Metadata.dataset@1[
+                        LiteralExpr [STRING] [Nation]
+                      ]
+                      AS
+                      Variable [ Name=n ]
+                    ]
+                    Where
+                      OperatorExpr [
+                        FieldAccessor [
+                          Variable [ Name=n ]
+                          Field=n_nationkey
+                        ]
+                        =
+                        FieldAccessor [
+                          Variable [ Name=s ]
+                          Field=s_nationkey
+                        ]
+                      ]
+                  )
+                  AS
+                  Variable [ Name=s1 ]
+,
+                  FunctionCall Metadata.dataset@1[
+                    LiteralExpr [STRING] [LineItem]
+                  ]
+                  AS
+                  Variable [ Name=l ]
+                ]
+                Where
+                  OperatorExpr [
+                    FieldAccessor [
+                      Variable [ Name=s1 ]
+                      Field=s_suppkey
+                    ]
+                    =
+                    FieldAccessor [
+                      Variable [ Name=l ]
+                      Field=l_suppkey
+                    ]
+                  ]
+              )
+              AS
+              Variable [ Name=l1 ]
+            ]
+            Where
+              OperatorExpr [
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_suppkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_suppkey
+                  ]
+                ]
+                and
+                OperatorExpr [
+                  FieldAccessor [
+                    Variable [ Name=ps ]
+                    Field=ps_partkey
+                  ]
+                  =
+                  FieldAccessor [
+                    Variable [ Name=l1 ]
+                    Field=l_partkey
+                  ]
+                ]
+              ]
+          )
+          AS
+          Variable [ Name=l2 ]
+        ]
+        Where
+          OperatorExpr [
+            FunctionCall tpch.contains@2[
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_name
+              ]
+              LiteralExpr [STRING] [green]
+            ]
+            and
+            OperatorExpr [
+              FieldAccessor [
+                Variable [ Name=p ]
+                Field=p_partkey
+              ]
+              =
+              FieldAccessor [
+                Variable [ Name=l2 ]
+                Field=l_partkey
+              ]
+            ]
+          ]
+      )
+      AS
+      Variable [ Name=l3 ]
+    ]
+    LetVariable [ Name=amount ]
+      :=
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=l3 ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        -
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=ps_supplycost
+          ]
+          *
+          FieldAccessor [
+            Variable [ Name=l3 ]
+            Field=l_quantity
+          ]
+        ]
+      ]
+    LetVariable [ Name=o_year ]
+      :=
+      FunctionCall tpch.get-year@1[
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderdate
+        ]
+      ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=o ]
+          Field=o_orderkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=l3 ]
+          Field=l_orderkey
+        ]
+      ]
+  )
+  AS
+  Variable [ Name=profit ]
+]
+Groupby
+  Variable [ Name=nation ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=nation
+  ]
+  Variable [ Name=o_year ]
+  :=
+  FieldAccessor [
+    Variable [ Name=profit ]
+    Field=o_year
+  ]
+  With
+  Variable [ Name=profit ]
+
+Orderby
+  Variable [ Name=nation ]
+  ASC
+  Variable [ Name=o_year ]
+  DESC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.1.ast
new file mode 100644
index 0000000..c0608a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.3.ast
new file mode 100644
index 0000000..4a81b19
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785-2/query-issue785-2.3.ast
@@ -0,0 +1,215 @@
+DataverseUse tpch
+Query:
+LetVariable [ Name=t ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [n_nationkey]
+        :
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_nationkey
+        ]
+      )
+      (
+        LiteralExpr [STRING] [n_name]
+        :
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_name
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=nation ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [SelectedNation]
+      ]
+      AS
+      Variable [ Name=sn ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=nation ]
+          Field=n_nationkey
+        ]
+        =
+        FieldAccessor [
+          Variable [ Name=sn ]
+          Field=n_nationkey
+        ]
+      ]
+  )
+LetVariable [ Name=X ]
+  :=
+  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation_key]
+        :
+        Variable [ Name=nation_key ]
+      )
+      (
+        LiteralExpr [STRING] [order_date]
+        :
+        Variable [ Name=orderdate ]
+      )
+      (
+        LiteralExpr [STRING] [sum_price]
+        :
+        Variable [ Name=sum ]
+      )
+    ]
+    ]
+    FROM [      Variable [ Name=t ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Customer]
+      ]
+      AS
+      Variable [ Name=customer ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=orders ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=orders ]
+            Field=o_custkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_custkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_nationkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=n ]
+            Field=n_nationkey
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=orderdate ]
+      :=
+      FieldAccessor [
+        Variable [ Name=orders ]
+        Field=o_orderdate
+      ]
+      Variable [ Name=nation_key ]
+      :=
+      FieldAccessor [
+        Variable [ Name=n ]
+        Field=n_nationkey
+      ]
+      With
+      Variable [ Name=orders ]
+      Variable [ Name=n ]
+      Variable [ Name=customer ]
+      Variable [ Name=X ]
+      Variable [ Name=t ]
+
+    LetVariable [ Name=sum ]
+      :=
+      FunctionCall tpch.sum@1[
+        (
+          SELECT ELEMENT [
+          FieldAccessor [
+            Variable [ Name=o ]
+            Field=o_totalprice
+          ]
+          ]
+          FROM [            Variable [ Name=orders ]
+            AS
+            Variable [ Name=o ]
+          ]
+        )
+      ]
+  )
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    Variable [ Name=nation_key ]
+  )
+  (
+    LiteralExpr [STRING] [sum_price]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [orderdate]
+          :
+          FieldAccessor [
+            Variable [ Name=y ]
+            Field=order_date
+          ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          FieldAccessor [
+            Variable [ Name=y ]
+            Field=sum_price
+          ]
+        )
+      ]
+      ]
+      FROM [        Variable [ Name=x ]
+        AS
+        Variable [ Name=y ]
+      ]
+      Orderby
+        FieldAccessor [
+          Variable [ Name=y ]
+          Field=sum_price
+        ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  Variable [ Name=X ]
+  AS
+  Variable [ Name=x ]
+]
+Groupby
+  Variable [ Name=nation_key ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=nation_key
+  ]
+  With
+  Variable [ Name=x ]
+  Variable [ Name=X ]
+  Variable [ Name=t ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.1.ast
new file mode 100644
index 0000000..c0608a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int64,
+    o_custkey : int64,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int64,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int64,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int64,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int64,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int64,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int64,
+    n_name : string,
+    n_regionkey : int64,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int64,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.3.ast
new file mode 100644
index 0000000..085714d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue785/query-issue785.3.ast
@@ -0,0 +1,177 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    Variable [ Name=nation_key ]
+  )
+  (
+    LiteralExpr [STRING] [sum_price]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [orderdate]
+          :
+          Variable [ Name=od ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          Variable [ Name=sum ]
+        )
+      ]
+      ]
+      FROM [        Variable [ Name=x ]
+        AS
+        Variable [ Name=i ]
+      ]
+      Groupby
+        Variable [ Name=od ]
+        :=
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=order_date
+        ]
+        With
+        Variable [ Name=i ]
+        Variable [ Name=x ]
+
+      LetVariable [ Name=sum ]
+        :=
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=s ]
+              Field=sum_price
+            ]
+            ]
+            FROM [              Variable [ Name=i ]
+              AS
+              Variable [ Name=s ]
+            ]
+          )
+        ]
+      Orderby
+        Variable [ Name=sum ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  (
+    SELECT ELEMENT [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [nation_key]
+        :
+        Variable [ Name=nation_key ]
+      )
+      (
+        LiteralExpr [STRING] [order_date]
+        :
+        Variable [ Name=orderdate ]
+      )
+      (
+        LiteralExpr [STRING] [sum_price]
+        :
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_totalprice
+            ]
+            ]
+            FROM [              Variable [ Name=orders ]
+              AS
+              Variable [ Name=o ]
+            ]
+          )
+        ]
+      )
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Nation]
+      ]
+      AS
+      Variable [ Name=n ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Customer]
+      ]
+      AS
+      Variable [ Name=customer ]
+,
+      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [Orders]
+      ]
+      AS
+      Variable [ Name=orders ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=orders ]
+            Field=o_custkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_custkey
+          ]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=customer ]
+            Field=c_nationkey
+          ]
+          =
+          FieldAccessor [
+            Variable [ Name=n ]
+            Field=n_nationkey
+          ]
+        ]
+      ]
+    Groupby
+      Variable [ Name=orderdate ]
+      :=
+      FieldAccessor [
+        Variable [ Name=orders ]
+        Field=o_orderdate
+      ]
+      Variable [ Name=nation_key ]
+      :=
+      FieldAccessor [
+        Variable [ Name=n ]
+        Field=n_nationkey
+      ]
+      With
+      Variable [ Name=orders ]
+      Variable [ Name=n ]
+      Variable [ Name=customer ]
+
+  )
+  AS
+  Variable [ Name=x ]
+]
+Groupby
+  Variable [ Name=nation_key ]
+  :=
+  FieldAccessor [
+    Variable [ Name=x ]
+    Field=nation_key
+  ]
+  With
+  Variable [ Name=x ]
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.1.ast
new file mode 100644
index 0000000..003faa7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.1.ast
@@ -0,0 +1,58 @@
+DataverseUse tpch
+TypeDecl OrderType [
+  closed RecordType {
+    o_orderkey : int32,
+    o_custkey : int32,
+    o_orderstatus : string,
+    o_totalprice : double,
+    o_orderdate : string,
+    o_orderpriority : string,
+    o_clerk : string,
+    o_shippriority : int32,
+    o_comment : string
+  }
+]
+TypeDecl CustomerType [
+  closed RecordType {
+    c_custkey : int32,
+    c_name : string,
+    c_address : string,
+    c_nationkey : int32,
+    c_phone : string,
+    c_acctbal : double,
+    c_mktsegment : string,
+    c_comment : string
+  }
+]
+TypeDecl SupplierType [
+  closed RecordType {
+    s_suppkey : int32,
+    s_name : string,
+    s_address : string,
+    s_nationkey : int32,
+    s_phone : string,
+    s_acctbal : double,
+    s_comment : string
+  }
+]
+TypeDecl NationType [
+  closed RecordType {
+    n_nationkey : int32,
+    n_name : string,
+    n_regionkey : int32,
+    n_comment : string
+  }
+]
+TypeDecl RegionType [
+  closed RecordType {
+    r_regionkey : int32,
+    r_name : string,
+    r_comment : string
+  }
+]
+DatasetDecl Orders(OrderType) partitioned by [[o_orderkey]]
+DatasetDecl Supplier(SupplierType) partitioned by [[s_suppkey]]
+DatasetDecl Region(RegionType) partitioned by [[r_regionkey]]
+DatasetDecl Nation(NationType) partitioned by [[n_nationkey]]
+DatasetDecl Customer(CustomerType) partitioned by [[c_custkey]]
+DatasetDecl SelectedNation(NationType) partitioned by [[n_nationkey]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.3.ast
new file mode 100644
index 0000000..dcd0269
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue786/query-issue786.3.ast
@@ -0,0 +1,139 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nation_key]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+  )
+  (
+    LiteralExpr [STRING] [name]
+    :
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_name
+    ]
+  )
+  (
+    LiteralExpr [STRING] [aggregates]
+    :
+    (
+      SELECT ELEMENT [
+      RecordConstructor [
+        (
+          LiteralExpr [STRING] [order_date]
+          :
+          Variable [ Name=orderdate ]
+        )
+        (
+          LiteralExpr [STRING] [sum_price]
+          :
+          Variable [ Name=sum ]
+        )
+      ]
+      ]
+      FROM [        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Orders]
+        ]
+        AS
+        Variable [ Name=orders ]
+,
+        FunctionCall Metadata.dataset@1[
+          LiteralExpr [STRING] [Customer]
+        ]
+        AS
+        Variable [ Name=customer ]
+      ]
+      Where
+        OperatorExpr [
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=orders ]
+              Field=o_custkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_custkey
+            ]
+          ]
+          and
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=customer ]
+              Field=c_nationkey
+            ]
+            =
+            FieldAccessor [
+              Variable [ Name=nation ]
+              Field=n_nationkey
+            ]
+          ]
+        ]
+      Groupby
+        Variable [ Name=orderdate ]
+        :=
+        FieldAccessor [
+          Variable [ Name=orders ]
+          Field=o_orderdate
+        ]
+        With
+        Variable [ Name=orders ]
+        Variable [ Name=customer ]
+        Variable [ Name=nation ]
+        Variable [ Name=sn ]
+
+      LetVariable [ Name=sum ]
+        :=
+        FunctionCall tpch.sum@1[
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=o ]
+              Field=o_totalprice
+            ]
+            ]
+            FROM [              Variable [ Name=orders ]
+              AS
+              Variable [ Name=o ]
+            ]
+          )
+        ]
+      Orderby
+        Variable [ Name=sum ]
+        DESC
+
+      Limit
+        LiteralExpr [LONG] [3]
+    )
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Nation]
+  ]
+  AS
+  Variable [ Name=nation ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [SelectedNation]
+  ]
+  AS
+  Variable [ Name=sn ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=nation ]
+      Field=n_nationkey
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=sn ]
+      Field=sn_nationkey
+    ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.1.ast
new file mode 100644
index 0000000..0abc90d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.3.ast
new file mode 100644
index 0000000..089c6df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-2/query-issue810-2.3.ast
@@ -0,0 +1,121 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [count_cheaps]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=cheaps ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [total_charges]
+    :
+    FunctionCall tpch.sum@1[
+      Variable [ Name=charges ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+LetVariable [ Name=cheaps ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=m ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=m ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=m ]
+          Field=l_discount
+        ]
+        >
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=charges ]
+  :=
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=l_discount
+        ]
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        +
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=l_tax
+        ]
+      ]
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=a ]
+    ]
+  )
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.1.ast
new file mode 100644
index 0000000..0abc90d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
new file mode 100644
index 0000000..acfa243
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
@@ -0,0 +1,183 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [count_cheaps]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=cheaps ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [avg_expensive_discounts]
+    :
+    FunctionCall tpch.avg@1[
+      Variable [ Name=expensives ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_prices]
+    :
+    FunctionCall tpch.sum@1[
+      Variable [ Name=disc_prices ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [total_charges]
+    :
+    FunctionCall tpch.sum@1[
+      Variable [ Name=charges ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+LetVariable [ Name=expensives ]
+  :=
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=i ]
+      Field=l_discount
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        <=
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=cheaps ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=i ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        >
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=charges ]
+  :=
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        +
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_tax
+        ]
+      ]
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+  )
+LetVariable [ Name=disc_prices ]
+  :=
+  (
+    SELECT ELEMENT [
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=i ]
+        Field=l_extendedprice
+      ]
+      *
+      OperatorExpr [
+        LiteralExpr [LONG] [1]
+        -
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+      ]
+    ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=i ]
+    ]
+  )
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.1.ast
new file mode 100644
index 0000000..0abc90d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
new file mode 100644
index 0000000..1b42b9f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
@@ -0,0 +1,107 @@
+DataverseUse tpch
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [l_returnflag]
+    :
+    Variable [ Name=l_returnflag ]
+  )
+  (
+    LiteralExpr [STRING] [l_linestatus]
+    :
+    Variable [ Name=l_linestatus ]
+  )
+  (
+    LiteralExpr [STRING] [count_cheaps]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=cheap ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_expensives]
+    :
+    FunctionCall tpch.count@1[
+      Variable [ Name=expensive ]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [LineItem]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=l_shipdate
+    ]
+    <=
+    LiteralExpr [STRING] [1998-09-02]
+  ]
+Groupby
+  Variable [ Name=l_returnflag ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_returnflag
+  ]
+  Variable [ Name=l_linestatus ]
+  :=
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=l_linestatus
+  ]
+  With
+  Variable [ Name=l ]
+
+LetVariable [ Name=cheap ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=m ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=m ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=m ]
+          Field=l_discount
+        ]
+        >
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+LetVariable [ Name=expensive ]
+  :=
+  (
+    SELECT ELEMENT [
+    Variable [ Name=a ]
+    ]
+    FROM [      Variable [ Name=l ]
+      AS
+      Variable [ Name=a ]
+    ]
+    Where
+      OperatorExpr [
+        FieldAccessor [
+          Variable [ Name=a ]
+          Field=l_discount
+        ]
+        <=
+        LiteralExpr [DOUBLE] [0.05]
+      ]
+  )
+Orderby
+  Variable [ Name=l_returnflag ]
+  ASC
+  Variable [ Name=l_linestatus ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.1.ast
new file mode 100644
index 0000000..0abc90d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.3.ast
new file mode 100644
index 0000000..54fa4ec
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827-2/query-issue827-2.3.ast
@@ -0,0 +1,210 @@
+DataverseUse tpch
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [sum_qty_partial]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_shipdate
+            ]
+            <=
+            LiteralExpr [STRING] [1998-09-02]
+          ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_base_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_disc_price]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [sum_charge]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=i ]
+            Field=l_extendedprice
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            -
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_discount
+            ]
+          ]
+          *
+          OperatorExpr [
+            LiteralExpr [LONG] [1]
+            +
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_tax
+            ]
+          ]
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_qty]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+        Where
+          OperatorExpr [
+            FieldAccessor [
+              Variable [ Name=i ]
+              Field=l_shipdate
+            ]
+            <=
+            LiteralExpr [STRING] [1998-09-02]
+          ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_price]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_extendedprice
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [ave_disc]
+    :
+    FunctionCall tpch.avg@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=i ]
+          Field=l_discount
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=i ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_order]
+    :
+    FunctionCall tpch.count@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=l ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.1.ast
new file mode 100644
index 0000000..0abc90d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.1.ast
@@ -0,0 +1,22 @@
+DataverseUse tpch
+TypeDecl LineItemType [
+  closed RecordType {
+    l_orderkey : int32,
+    l_partkey : int32,
+    l_suppkey : int32,
+    l_linenumber : int32,
+    l_quantity : double,
+    l_extendedprice : double,
+    l_discount : double,
+    l_tax : double,
+    l_returnflag : string,
+    l_linestatus : string,
+    l_shipdate : string,
+    l_commitdate : string,
+    l_receiptdate : string,
+    l_shipinstruct : string,
+    l_shipmode : string,
+    l_comment : string
+  }
+]
+DatasetDecl LineItem(LineItemType) partitioned by [[l_orderkey], [l_linenumber]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.2.ast
new file mode 100644
index 0000000..0a5cca1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.2.ast
@@ -0,0 +1 @@
+DataverseUse tpch
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.3.ast
new file mode 100644
index 0000000..1772697
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue827/query-issue827.3.ast
@@ -0,0 +1,52 @@
+DataverseUse tpch
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [count_cheaps]
+    :
+    FunctionCall tpch.count@1[
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=l ]
+          Field=l_quantity
+        ]
+        ]
+        FROM [          FunctionCall Metadata.dataset@1[
+            LiteralExpr [STRING] [LineItem]
+          ]
+          AS
+          Variable [ Name=l ]
+        ]
+      )
+    ]
+  )
+  (
+    LiteralExpr [STRING] [count_expensives]
+    :
+    FunctionCall tpch.sum@1[
+      (
+        SELECT ELEMENT [
+        Variable [ Name=e ]
+        ]
+        FROM [          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=l ]
+              Field=l_extendedprice
+            ]
+            ]
+            FROM [              FunctionCall Metadata.dataset@1[
+                LiteralExpr [STRING] [LineItem]
+              ]
+              AS
+              Variable [ Name=l ]
+            ]
+          )
+          AS
+          Variable [ Name=e ]
+        ]
+      )
+    ]
+  )
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.3.ast
new file mode 100644
index 0000000..7c249a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/opentype_orderby_01/opentype_orderby_01.3.ast
@@ -0,0 +1,40 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.3.ast
new file mode 100644
index 0000000..6629906
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_01/promotion_closedtype_field_vs_closedtype_field_01.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.dsince]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dsince
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dsince
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=dsince
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.3.ast
new file mode 100644
index 0000000..0c15385
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_02/promotion_closedtype_field_vs_closedtype_field_02.3.ast
@@ -0,0 +1,92 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.bossidint32 + 2000]
+    :
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=dept ]
+        Field=bossidint32
+      ]
+      +
+      LiteralExpr [LONG] [2000]
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    OperatorExpr [
+      FieldAccessor [
+        Variable [ Name=dept ]
+        Field=bossidint32
+      ]
+      +
+      LiteralExpr [LONG] [2000]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=bossidint32
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.3.ast
new file mode 100644
index 0000000..2dd04ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_03/promotion_closedtype_field_vs_closedtype_field_03.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.bossid]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=bossid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=bossid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=bossid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.3.ast
new file mode 100644
index 0000000..74eecbe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_04/promotion_closedtype_field_vs_closedtype_field_04.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.bossidint32]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=bossidint32
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=bossidint32
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=bossidint32
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.1.ast
new file mode 100644
index 0000000..a27e5b0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.1.ast
@@ -0,0 +1,17 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dno : int32,
+    dname : string
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.3.ast
new file mode 100644
index 0000000..b585f88
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_closedtype_field_05/promotion_closedtype_field_vs_closedtype_field_05.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.empno]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=empno
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.dno]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dno
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=empno
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dno
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=empno
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=dno
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.3.ast
new file mode 100644
index 0000000..02b5f0e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_01/promotion_closedtype_field_vs_constant_01.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FunctionCall test.int8@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.3.ast
new file mode 100644
index 0000000..f51b604
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_02/promotion_closedtype_field_vs_constant_02.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FunctionCall test.int16@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.3.ast
new file mode 100644
index 0000000..e5ebaf1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_03/promotion_closedtype_field_vs_constant_03.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.3.ast
new file mode 100644
index 0000000..777b12c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_04/promotion_closedtype_field_vs_constant_04.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.3.ast
new file mode 100644
index 0000000..c2ec21c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_05/promotion_closedtype_field_vs_constant_05.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.3.ast
new file mode 100644
index 0000000..777b12c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_06/promotion_closedtype_field_vs_constant_06.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.age]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=age
+    ]
+    =
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=age
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.3.ast
new file mode 100644
index 0000000..214e38e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_07/promotion_closedtype_field_vs_constant_07.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    FunctionCall test.int16@1[
+      LiteralExpr [STRING] [2001]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.3.ast
new file mode 100644
index 0000000..7ee46ca
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_08/promotion_closedtype_field_vs_constant_08.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [2001]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.3.ast
new file mode 100644
index 0000000..22722fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_09/promotion_closedtype_field_vs_constant_09.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [2001]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.3.ast
new file mode 100644
index 0000000..5086dda
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_10/promotion_closedtype_field_vs_constant_10.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [2001]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.3.ast
new file mode 100644
index 0000000..07a5b65
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_constant_11/promotion_closedtype_field_vs_constant_11.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.worksince]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=worksince
+    ]
+    =
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [2001]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=worksince
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.3.ast
new file mode 100644
index 0000000..27559d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_01/promotion_closedtype_field_vs_opentype_field_01.3.ast
@@ -0,0 +1,79 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.bossid]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=bossid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.suprvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=bossid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.3.ast
new file mode 100644
index 0000000..9f9c288
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_02/promotion_closedtype_field_vs_opentype_field_02.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.floor]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=floor
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=floor
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=floor
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.3.ast
new file mode 100644
index 0000000..44fbf52
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_03/promotion_closedtype_field_vs_opentype_field_03.3.ast
@@ -0,0 +1,84 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.empno]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=empno
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.dmgrid]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=empno
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=empno
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=dmgrid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.3.ast
new file mode 100644
index 0000000..1fe8d41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_closedtype_field_vs_opentype_field_04/promotion_closedtype_field_vs_opentype_field_04.3.ast
@@ -0,0 +1,76 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.did]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=did
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.dmgrid]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=dmgrid
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=dept ]
+    Field=did
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.3.ast
new file mode 100644
index 0000000..8009cba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_01/promotion_opentype_field_vs_constant_01.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.int8@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.3.ast
new file mode 100644
index 0000000..de2723f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_02/promotion_opentype_field_vs_constant_02.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.int16@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.3.ast
new file mode 100644
index 0000000..1890f69
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_03/promotion_opentype_field_vs_constant_03.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.int32@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.3.ast
new file mode 100644
index 0000000..48c2353
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_04/promotion_opentype_field_vs_constant_04.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.int64@1[
+      LiteralExpr [STRING] [1]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.3.ast
new file mode 100644
index 0000000..ad390f5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_05/promotion_opentype_field_vs_constant_05.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.float@1[
+      LiteralExpr [STRING] [1.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.3.ast
new file mode 100644
index 0000000..9e86eb4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_06/promotion_opentype_field_vs_constant_06.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.double@1[
+      LiteralExpr [STRING] [1.0]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.3.ast
new file mode 100644
index 0000000..49d1656
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_07/promotion_opentype_field_vs_constant_07.3.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    LiteralExpr [STRING] [1]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.3.ast
new file mode 100644
index 0000000..e0398c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_constant_08/promotion_opentype_field_vs_constant_08.3.ast
@@ -0,0 +1,51 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.supvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FunctionCall test.point@1[
+      LiteralExpr [STRING] [80.10d, -10E5]
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=supvrid
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.3.ast
new file mode 100644
index 0000000..ca35d9a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_01/promotion_opentype_field_vs_opentype_field_01.3.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.suprvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.dmgrid2]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid2
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid2
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.1.ast
new file mode 100644
index 0000000..60b61a6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.1.ast
@@ -0,0 +1,23 @@
+DataverseUse test
+TypeDecl empInfoType [
+  open RecordType {
+    id : int64,
+    empno : int64,
+    name : string,
+    height : float,
+    age : int64,
+    worksince : int64
+  }
+]
+TypeDecl deptInfoType [
+  open RecordType {
+    did : int64,
+    dname : string,
+    floor : int64,
+    dsince : int64,
+    bossid : int64,
+    bossidint32 : int32
+  }
+]
+DatasetDecl empDataset(empInfoType) partitioned by [[id]]
+DatasetDecl deptDataset(deptInfoType) partitioned by [[did]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.3.ast
new file mode 100644
index 0000000..f639cd0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/promotion_opentype_field_vs_opentype_field_02/promotion_opentype_field_vs_opentype_field_02.3.ast
@@ -0,0 +1,61 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [emp.id]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=id
+    ]
+  )
+  (
+    LiteralExpr [STRING] [emp.suprvrid]
+    :
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  )
+  (
+    LiteralExpr [STRING] [dept.dmgrid2]
+    :
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid2
+    ]
+  )
+]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [empDataset]
+  ]
+  AS
+  Variable [ Name=emp ]
+,
+  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [deptDataset]
+  ]
+  AS
+  Variable [ Name=dept ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=dept ]
+      Field=dmgrid2
+    ]
+    =
+    FieldAccessor [
+      Variable [ Name=emp ]
+      Field=supvrid
+    ]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=emp ]
+    Field=id
+  ]
+  ASC
+
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/record01/record01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/record01/record01.1.ast
new file mode 100644
index 0000000..a48fd55
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/record01/record01.1.ast
@@ -0,0 +1,7 @@
+DataverseUse local
+TypeDecl ttype [
+  open RecordType {
+    id : int32
+  }
+]
+DatasetDecl dset(ttype) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.1.ast
new file mode 100644
index 0000000..cb97dc1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.1.ast
@@ -0,0 +1,16 @@
+DataverseUse TestVerse
+TypeDecl Int64TestType [
+  open RecordType {
+    myint64 : int64,
+    myoptint64 : int64?,
+    myint32 : int32,
+    myoptint32 : int32?,
+    myint16 : int16,
+    myoptint16 : int16?,
+    mydouble : double,
+    myoptdouble : double?,
+    myfloat : float,
+    myoptfloat : float?
+  }
+]
+DatasetDecl Int64Test(Int64TestType) partitioned by [[myint64]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.2.ast
new file mode 100644
index 0000000..3efb4be
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.2.ast
@@ -0,0 +1 @@
+DataverseUse TestVerse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.3.ast
new file mode 100644
index 0000000..b7ae27c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_0/type_promotion_0.3.ast
@@ -0,0 +1,11 @@
+DataverseUse TestVerse
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Int64Test]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.1.ast
new file mode 100644
index 0000000..126f089
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.1.ast
@@ -0,0 +1,31 @@
+DataverseUse TestDataverse
+TypeDecl TestType [
+  open RecordType {
+    id : int64,
+    int8_u : UnorderedList <int8>
+,
+    int8_o : OrderedList [int8]
+,
+    int16_u : UnorderedList <int16>
+,
+    int16_o : OrderedList [int16]
+,
+    int32_u : UnorderedList <int32>
+,
+    int32_o : OrderedList [int32]
+,
+    int64_u : UnorderedList <int64>
+,
+    int64_o : OrderedList [int64]
+,
+    float_u : UnorderedList <float>
+,
+    float_o : OrderedList [float]
+,
+    double_u : UnorderedList <double>
+,
+    double_o : OrderedList [double]
+
+  }
+]
+DatasetDecl TestSet(TestType) partitioned by [[id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.2.ast
new file mode 100644
index 0000000..0da3f75
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.2.ast
@@ -0,0 +1 @@
+DataverseUse TestDataverse
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.3.ast
new file mode 100644
index 0000000..4c16b66
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/types/type_promotion_1/type_promotion_1.3.ast
@@ -0,0 +1,11 @@
+DataverseUse TestDataverse
+Query:
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [TestSet]
+  ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.1.ast
new file mode 100644
index 0000000..e339672
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.1.ast
@@ -0,0 +1,13 @@
+DataverseUse TinySocial
+TypeDecl FacebookUserType [
+  open RecordType {
+    id : int64
+  }
+]
+TypeDecl FacebookMessageType [
+  open RecordType {
+    message_id : int64
+  }
+]
+DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
+DatasetDecl FacebookMessages(FacebookMessageType) partitioned by [[message_id]]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.2.ast
new file mode 100644
index 0000000..f36d0ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.2.ast
@@ -0,0 +1 @@
+DataverseUse TinySocial
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/union/union/union.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.1.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.1.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.3.ast
new file mode 100644
index 0000000..2cc07c8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/f01/f01.3.ast
@@ -0,0 +1,4 @@
+DataverseUse test
+Query:
+FunctionCall test.int8@0[
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.3.ast
new file mode 100644
index 0000000..5b72053
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/invoke-private-function/invoke-private-function.3.ast
@@ -0,0 +1,133 @@
+DataverseUse test
+Query:
+LetVariable [ Name=a ]
+  :=
+  OrderedListConstructor [
+  ]
+LetVariable [ Name=b ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+  ]
+LetVariable [ Name=c ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+  ]
+LetVariable [ Name=d ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [jkl]
+  ]
+LetVariable [ Name=e ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [cde]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+  ]
+LetVariable [ Name=f ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=g ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [Efg]
+    LiteralExpr [STRING] [aBc]
+    LiteralExpr [STRING] [cdE]
+    LiteralExpr [STRING] [DEf]
+    LiteralExpr [STRING] [hIJ]
+    LiteralExpr [STRING] [IjK]
+    LiteralExpr [STRING] [BCD]
+  ]
+LetVariable [ Name=h ]
+  :=
+  OrderedListConstructor [
+    LiteralExpr [STRING] [abc]
+    LiteralExpr [STRING] [ijk]
+    LiteralExpr [STRING] [bcd]
+    LiteralExpr [STRING] [efg]
+    LiteralExpr [STRING] [fgh]
+    LiteralExpr [STRING] [ghi]
+    LiteralExpr [STRING] [def]
+    LiteralExpr [STRING] [hij]
+    LiteralExpr [STRING] [jkl]
+    LiteralExpr [STRING] [cde]
+  ]
+LetVariable [ Name=results ]
+  :=
+  OrderedListConstructor [
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=a ]
+      Variable [ Name=b ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=b ]
+      Variable [ Name=a ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=c ]
+      Variable [ Name=d ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=d ]
+      Variable [ Name=c ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=e ]
+      Variable [ Name=f ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=f ]
+      Variable [ Name=e ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=g ]
+      Variable [ Name=h ]
+    ]
+    FunctionCall test.similarity-jaccard@2[
+      Variable [ Name=h ]
+      Variable [ Name=g ]
+    ]
+  ]
+SELECT ELEMENT [
+Variable [ Name=i ]
+]
+FROM [  Variable [ Name=results ]
+  AS
+  Variable [ Name=i ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue172/query-issue172.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue201/query-issue201.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218-2/query-issue218-2.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue218/query-issue218.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue244/query-issue244.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.5.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.5.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue455/query-issue455.5.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.3.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.3.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.4.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.4.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/query-issue489/query-issue489.4.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.3.ast
new file mode 100644
index 0000000..7c29aef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf01/udf01.3.ast
@@ -0,0 +1,22 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.echo@1[
+  Variable [ Name=a ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [10]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.3.ast
new file mode 100644
index 0000000..2909914
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf02/udf02.3.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.getFirst@1[
+  Variable [ Name=a ]
+]
+]
+FROM [  OrderedListConstructor [
+    OrderedListConstructor [
+      LiteralExpr [LONG] [1]
+      LiteralExpr [LONG] [2]
+    ]
+    OrderedListConstructor [
+      LiteralExpr [LONG] [3]
+      LiteralExpr [LONG] [4]
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.3.ast
new file mode 100644
index 0000000..de11c09
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf04/udf04.3.ast
@@ -0,0 +1,63 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.echo@1[
+  Variable [ Name=a ]
+]
+]
+FROM [  OrderedListConstructor [
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [name]
+        :
+        LiteralExpr [STRING] [John]
+      )
+      (
+        LiteralExpr [STRING] [age]
+        :
+        LiteralExpr [LONG] [45]
+      )
+      (
+        LiteralExpr [STRING] [id]
+        :
+        LiteralExpr [LONG] [123]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [name]
+        :
+        LiteralExpr [STRING] [Jim]
+      )
+      (
+        LiteralExpr [STRING] [age]
+        :
+        LiteralExpr [LONG] [55]
+      )
+      (
+        LiteralExpr [STRING] [id]
+        :
+        LiteralExpr [LONG] [103]
+      )
+    ]
+    RecordConstructor [
+      (
+        LiteralExpr [STRING] [name]
+        :
+        LiteralExpr [STRING] [Bill]
+      )
+      (
+        LiteralExpr [STRING] [age]
+        :
+        LiteralExpr [LONG] [35]
+      )
+      (
+        LiteralExpr [STRING] [id]
+        :
+        LiteralExpr [LONG] [125]
+      )
+    ]
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.3.ast
new file mode 100644
index 0000000..f800f48
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf05/udf05.3.ast
@@ -0,0 +1,5 @@
+DataverseUse test
+Query:
+FunctionCall test.echo@1[
+  LiteralExpr [LONG] [1234]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.3.ast
new file mode 100644
index 0000000..971ddfa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf06/udf06.3.ast
@@ -0,0 +1,5 @@
+DataverseUse test
+Query:
+FunctionCall test.echo@1[
+  LiteralExpr [DOUBLE] [1234.1]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.3.ast
new file mode 100644
index 0000000..0cf70df
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf07/udf07.3.ast
@@ -0,0 +1,5 @@
+DataverseUse test
+Query:
+FunctionCall test.echo@1[
+  LiteralExpr [FLOAT] [1234.1]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.3.ast
new file mode 100644
index 0000000..c74a938
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf08/udf08.3.ast
@@ -0,0 +1,5 @@
+DataverseUse test
+Query:
+FunctionCall test.echo@1[
+  LiteralExpr [STRING] [This is a test string]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.2.ast
new file mode 100644
index 0000000..916a59e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.2.ast
@@ -0,0 +1 @@
+DataverseUse test
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.3.ast
new file mode 100644
index 0000000..fffc5fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf09/udf09.3.ast
@@ -0,0 +1,24 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.readDataset@1[
+  (
+    SELECT ELEMENT [
+    Variable [ Name=a ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [test.t1]
+      ]
+      AS
+      Variable [ Name=a ]
+    ]
+    Orderby
+      FieldAccessor [
+        Variable [ Name=a ]
+        Field=id
+      ]
+      ASC
+
+  )
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.3.ast
new file mode 100644
index 0000000..932d119
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf10/udf10.3.ast
@@ -0,0 +1,9 @@
+DataverseUse test
+Query:
+FunctionCall test.echo@1[
+  UnorderedListConstructor [
+    LiteralExpr [STRING] [this is optional data]
+    LiteralExpr [STRING] [this is extra data]
+    LiteralExpr [STRING] [open types are good]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.3.ast
new file mode 100644
index 0000000..91115be
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf11/udf11.3.ast
@@ -0,0 +1,10 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  FunctionCall test.OList@0[
+  ]
+  AS
+  Variable [ Name=a ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.3.ast
new file mode 100644
index 0000000..4289a98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf12/udf12.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.foo@2[
+  LiteralExpr [LONG] [100]
+  LiteralExpr [LONG] [200]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.3.ast
new file mode 100644
index 0000000..010b3d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf13/udf13.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.foo@2[
+  LiteralExpr [LONG] [400]
+  LiteralExpr [LONG] [200]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.3.ast
new file mode 100644
index 0000000..010b3d7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf14/udf14.3.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.foo@2[
+  LiteralExpr [LONG] [400]
+  LiteralExpr [LONG] [200]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.3.ast
new file mode 100644
index 0000000..e095df3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf16/udf16.3.ast
@@ -0,0 +1,6 @@
+DataverseUse test
+Query:
+FunctionCall test.string-length@1[
+  FunctionCall test.fn02@0[
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.3.ast
new file mode 100644
index 0000000..22111b1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf17/udf17.3.ast
@@ -0,0 +1,4 @@
+DataverseUse test
+Query:
+FunctionCall test.parent@0[
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.3.ast
new file mode 100644
index 0000000..c25ac31
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf18/udf18.3.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+Set import-private-functions=true
+Query:
+FunctionCall test.not@1[
+  FunctionCall test.fn06@0[
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.3.ast
new file mode 100644
index 0000000..3867fbf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf19/udf19.3.ast
@@ -0,0 +1,26 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.area@1[
+  Variable [ Name=a ]
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [12]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.area@1[
+      Variable [ Name=a ]
+    ]
+    >
+    LiteralExpr [LONG] [100]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.3.ast
new file mode 100644
index 0000000..e12af84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf20/udf20.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [radius]
+    :
+    Variable [ Name=a ]
+  )
+  (
+    LiteralExpr [STRING] [area]
+    :
+    FunctionCall test.area@1[
+      Variable [ Name=a ]
+    ]
+  )
+]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [8]
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [12]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Where
+  OperatorExpr [
+    FunctionCall test.area@1[
+      Variable [ Name=a ]
+    ]
+    >
+    LiteralExpr [LONG] [100]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.3.ast
new file mode 100644
index 0000000..2feced9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf21/udf21.3.ast
@@ -0,0 +1,37 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=a ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [LONG] [10]
+    LiteralExpr [LONG] [20]
+    LiteralExpr [LONG] [2]
+    LiteralExpr [LONG] [30]
+    LiteralExpr [LONG] [4]
+    LiteralExpr [LONG] [3]
+    LiteralExpr [LONG] [6]
+    LiteralExpr [LONG] [44]
+    LiteralExpr [LONG] [5]
+    LiteralExpr [LONG] [7]
+    LiteralExpr [LONG] [9]
+    LiteralExpr [LONG] [1]
+    LiteralExpr [LONG] [13]
+    LiteralExpr [LONG] [17]
+    LiteralExpr [LONG] [992]
+    LiteralExpr [LONG] [19]
+    LiteralExpr [LONG] [40]
+    LiteralExpr [LONG] [50]
+    LiteralExpr [LONG] [60]
+    LiteralExpr [LONG] [25]
+    LiteralExpr [LONG] [45]
+    LiteralExpr [LONG] [65]
+    LiteralExpr [LONG] [75]
+  ]
+  AS
+  Variable [ Name=a ]
+]
+Where
+  FunctionCall test.isOdd@1[
+    Variable [ Name=a ]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.3.ast
new file mode 100644
index 0000000..a05dee9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf22/udf22.3.ast
@@ -0,0 +1,6 @@
+DataverseUse test
+Query:
+FunctionCall test.getFullName@2[
+  LiteralExpr [STRING] [Bob]
+  LiteralExpr [STRING] [Harbus]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.3.ast
new file mode 100644
index 0000000..418a454
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf23/udf23.3.ast
@@ -0,0 +1,30 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=l ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Dataset]
+  ]
+  AS
+  Variable [ Name=l ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=l ]
+      Field=DataverseName
+    ]
+    =
+    LiteralExpr [STRING] [Metadata]
+  ]
+Orderby
+  FieldAccessor [
+    Variable [ Name=l ]
+    Field=DatasetName
+  ]
+  ASC
+
+Limit
+  FunctionCall test.numRows@0[
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.3.ast
new file mode 100644
index 0000000..c2db2b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf26/udf26.3.ast
@@ -0,0 +1,7 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+FunctionCall test.needs_f1@1[
+  LiteralExpr [LONG] [12345]
+]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.3.ast
new file mode 100644
index 0000000..8023b42
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf27/udf27.3.ast
@@ -0,0 +1,19 @@
+DataverseUse test
+Query:
+QuantifiedExpression SOME [
+  [Variable [ Name=i ]
+  In
+    OrderedListConstructor [
+      LiteralExpr [LONG] [100]
+      LiteralExpr [LONG] [200]
+    ]
+  ]
+  Satifies [
+    OperatorExpr [
+      Variable [ Name=i ]
+      <
+      FunctionCall test.f1@0[
+      ]
+    ]
+  ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf28/udf28.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf28/udf28.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf28/udf28.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf28/udf28.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf28/udf28.2.ast
new file mode 100644
index 0000000..b04f125
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf28/udf28.2.ast
@@ -0,0 +1,20 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  FunctionCall Metadata.dataset@1[
+    LiteralExpr [STRING] [Metadata.Function]
+  ]
+  AS
+  Variable [ Name=x ]
+]
+Where
+  OperatorExpr [
+    FieldAccessor [
+      Variable [ Name=x ]
+      Field=DataverseName
+    ]
+    =
+    LiteralExpr [STRING] [test]
+  ]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf29/udf29.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf29/udf29.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf29/udf29.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf29/udf29.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf29/udf29.2.ast
new file mode 100644
index 0000000..870028d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf29/udf29.2.ast
@@ -0,0 +1,8 @@
+DataverseUse test
+FunctionDecl f1([]) {
+  LiteralExpr [LONG] [100]
+}
+
+Query:
+FunctionCall test.f1@0[
+]
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf30/udf30.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf30/udf30.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/user-defined-functions/udf30/udf30.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.1.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.1.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.1.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.2.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.2.ast
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.2.ast
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.3.ast
new file mode 100644
index 0000000..ba3aeaa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/writers/print_01/print_01.3.ast
@@ -0,0 +1,12 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=x ]
+]
+FROM [  OrderedListConstructor [
+    LiteralExpr [STRING] [foo]
+    LiteralExpr [STRING] [bar]
+  ]
+  AS
+  Variable [ Name=x ]
+]
diff --git a/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml b/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
new file mode 100644
index 0000000..bb7128a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
@@ -0,0 +1,6810 @@
+<!--
+ ! 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.
+ !-->
+<!DOCTYPE test-suite [
+
+<!ENTITY RecordsQueries SYSTEM "queries/records/RecordsQueries.xml">
+
+]>
+<test-suite
+        xmlns="urn:xml.testframework.asterix.apache.org"
+        ResultOffsetPath="results_parser_sqlpp"
+        QueryOffsetPath="queries_sqlpp"
+        QueryFileExtension=".sqlpp">
+    <test-group name="flwor">
+        <test-case FilePath="flwor">
+            <compilation-unit name="at00">
+                <output-dir compare="AST">at00</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="at01">
+                <output-dir compare="AST">at01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="at02">
+                <output-dir compare="AST">at02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="at03">
+                <output-dir compare="AST">at03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="at04">
+                <output-dir compare="AST">at04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="at05">
+                <output-dir compare="AST">at05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="at06">
+                <output-dir compare="AST">at06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="flwor">
+            <compilation-unit name="query-issue550">
+                <output-dir compare="AST">query-issue550</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <!-- 
+    <test-group name="union">
+        <test-case FilePath="union">
+            <compilation-unit name="union">
+                <output-dir compare="AST">union</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    -->
+    <test-case FilePath="flwor">
+        <compilation-unit name="let33">
+            <output-dir compare="AST">let33</output-dir>
+        </compilation-unit>
+    </test-case>
+    <test-group name="aggregate">
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue531_string_min_max">
+                <output-dir compare="AST">issue531_string_min_max</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="agg_null">
+                <output-dir compare="AST">agg_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="agg_null_rec">
+                <output-dir compare="AST">agg_null_rec</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="agg_null_rec_1">
+                <output-dir compare="AST">agg_null_rec_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="agg_number_rec">
+                <output-dir compare="AST">agg_number_rec</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_mixed">
+                <output-dir compare="AST">avg_mixed</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_mixed">
+                <output-dir compare="AST">sum_mixed</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="min_mixed">
+                <output-dir compare="AST">min_mixed</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="agg_number">
+                <output-dir compare="AST">agg_number</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue425_min_hetero_list_1">
+                <output-dir compare="AST">issue425_min_hetero_list_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue425_min_hetero_list">
+                <output-dir compare="AST">issue425_min_hetero_list</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue425_sum_hetero_list_1">
+                <output-dir compare="AST">issue425_sum_hetero_list_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue425_sum_hetero_list">
+                <output-dir compare="AST">issue425_sum_hetero_list</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="query-issue400">
+                <output-dir compare="AST">query-issue400</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue395">
+                <output-dir compare="AST">issue395</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue412_0">
+                <output-dir compare="AST">issue412_0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="issue412_1">
+                <output-dir compare="AST">issue412_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_double">
+                <output-dir compare="AST">avg_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_double_null">
+                <output-dir compare="AST">avg_double_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_empty_01">
+                <output-dir compare="AST">avg_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_empty_02">
+                <output-dir compare="AST">avg_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_float">
+                <output-dir compare="AST">avg_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_float_null">
+                <output-dir compare="AST">avg_float_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int16">
+                <output-dir compare="AST">avg_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int16_null">
+                <output-dir compare="AST">avg_int16_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int32">
+                <output-dir compare="AST">avg_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int32_null">
+                <output-dir compare="AST">avg_int32_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int64">
+                <output-dir compare="AST">avg_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int64_null">
+                <output-dir compare="AST">avg_int64_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int8">
+                <output-dir compare="AST">avg_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="avg_int8_null">
+                <output-dir compare="AST">avg_int8_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="count_01">
+                <output-dir compare="AST">count_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="count_empty_01">
+                <output-dir compare="AST">count_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="count_empty_02">
+                <output-dir compare="AST">count_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="count_null">
+                <output-dir compare="AST">count_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="aggregate">
+          <compilation-unit name="droptype">
+            <output-dir compare="AST">droptype</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!-- TODO(madhusudancs): These tests that test for local_<agg>/global_<agg> functions should be removed, but
+        before that we should modify the code to make sure those built-in functions are still defined but not exposed
+        by AQL, so leaving these test cases commented.
+        <test-case FilePath="aggregate">
+          <compilation-unit name="global-avg_01">
+            <output-dir compare="AST">global-avg_01</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="global-avg_null">
+            <output-dir compare="AST">global-avg_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_double">
+            <output-dir compare="AST">local-avg_double</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_double_null">
+            <output-dir compare="AST">local-avg_double_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_float">
+            <output-dir compare="AST">local-avg_float</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_float_null">
+            <output-dir compare="AST">local-avg_float_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int16">
+            <output-dir compare="AST">local-avg_int16</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int16_null">
+            <output-dir compare="AST">local-avg_int16_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int32">
+            <output-dir compare="AST">local-avg_int32</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int32_null">
+            <output-dir compare="AST">local-avg_int32_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int64">
+            <output-dir compare="AST">local-avg_int64</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int64_null">
+            <output-dir compare="AST">local-avg_int64_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int8">
+            <output-dir compare="AST">local-avg_int8</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+          <compilation-unit name="local-avg_int8_null">
+            <output-dir compare="AST">local-avg_int8_null</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="aggregate">
+            <compilation-unit name="max_empty_01">
+                <output-dir compare="AST">max_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="max_empty_02">
+                <output-dir compare="AST">max_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="min_empty_01">
+                <output-dir compare="AST">min_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="min_empty_02">
+                <output-dir compare="AST">min_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_avg">
+                <output-dir compare="AST">scalar_avg</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_avg_empty">
+                <output-dir compare="AST">scalar_avg_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_avg_null">
+                <output-dir compare="AST">scalar_avg_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_count">
+                <output-dir compare="AST">scalar_count</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_count_empty">
+                <output-dir compare="AST">scalar_count_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_count_null">
+                <output-dir compare="AST">scalar_count_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_max">
+                <output-dir compare="AST">scalar_max</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_max_empty">
+                <output-dir compare="AST">scalar_max_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_max_null">
+                <output-dir compare="AST">scalar_max_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_min">
+                <output-dir compare="AST">scalar_min</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_min_empty">
+                <output-dir compare="AST">scalar_min_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_min_null">
+                <output-dir compare="AST">scalar_min_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_sum">
+                <output-dir compare="AST">scalar_sum</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_sum_empty">
+                <output-dir compare="AST">scalar_sum_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="scalar_sum_null">
+                <output-dir compare="AST">scalar_sum_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_double">
+                <output-dir compare="AST">sum_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_double_null">
+                <output-dir compare="AST">sum_double_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_empty_01">
+                <output-dir compare="AST">sum_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_empty_02">
+                <output-dir compare="AST">sum_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_float">
+                <output-dir compare="AST">sum_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_float_null">
+                <output-dir compare="AST">sum_float_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int16">
+                <output-dir compare="AST">sum_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int16_null">
+                <output-dir compare="AST">sum_int16_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int32">
+                <output-dir compare="AST">sum_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int32_null">
+                <output-dir compare="AST">sum_int32_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int64">
+                <output-dir compare="AST">sum_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int64_null">
+                <output-dir compare="AST">sum_int64_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int8">
+                <output-dir compare="AST">sum_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_int8_null">
+                <output-dir compare="AST">sum_int8_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_null-with-pred">
+                <output-dir compare="AST">sum_null-with-pred</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate">
+            <compilation-unit name="sum_numeric_null">
+                <output-dir compare="AST">sum_numeric_null</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="aggregate-sql">
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue531_string_min_max">
+                <output-dir compare="AST">issue531_string_min_max</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="agg_null">
+                <output-dir compare="AST">agg_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="agg_null_rec">
+                <output-dir compare="AST">agg_null_rec</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="agg_null_rec_1">
+                <output-dir compare="AST">agg_null_rec_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="agg_number_rec">
+                <output-dir compare="AST">agg_number_rec</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_mixed">
+                <output-dir compare="AST">avg_mixed</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_mixed">
+                <output-dir compare="AST">sum_mixed</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="min_mixed">
+                <output-dir compare="AST">min_mixed</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="agg_number">
+                <output-dir compare="AST">agg_number</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue425_min_hetero_list_1">
+                <output-dir compare="AST">issue425_min_hetero_list_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue425_min_hetero_list">
+                <output-dir compare="AST">issue425_min_hetero_list</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue425_sum_hetero_list_1">
+                <output-dir compare="AST">issue425_sum_hetero_list_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue425_sum_hetero_list">
+                <output-dir compare="AST">issue425_sum_hetero_list</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="query-issue400">
+                <output-dir compare="AST">query-issue400</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue395">
+                <output-dir compare="AST">issue395</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue412_0">
+                <output-dir compare="AST">issue412_0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="issue412_1">
+                <output-dir compare="AST">issue412_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_double">
+                <output-dir compare="AST">avg_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_double_null">
+                <output-dir compare="AST">avg_double_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_empty_01">
+                <output-dir compare="AST">avg_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_empty_02">
+                <output-dir compare="AST">avg_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_float">
+                <output-dir compare="AST">avg_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_float_null">
+                <output-dir compare="AST">avg_float_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int16">
+                <output-dir compare="AST">avg_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int16_null">
+                <output-dir compare="AST">avg_int16_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int32">
+                <output-dir compare="AST">avg_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int32_null">
+                <output-dir compare="AST">avg_int32_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int64">
+                <output-dir compare="AST">avg_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int64_null">
+                <output-dir compare="AST">avg_int64_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int8">
+                <output-dir compare="AST">avg_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="avg_int8_null">
+                <output-dir compare="AST">avg_int8_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="count_01">
+                <output-dir compare="AST">count_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="count_empty_01">
+                <output-dir compare="AST">count_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="count_empty_02">
+                <output-dir compare="AST">count_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="count_null">
+                <output-dir compare="AST">count_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="max_empty_01">
+                <output-dir compare="AST">max_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="max_empty_02">
+                <output-dir compare="AST">max_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="min_empty_01">
+                <output-dir compare="AST">min_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="min_empty_02">
+                <output-dir compare="AST">min_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_avg">
+                <output-dir compare="AST">scalar_avg</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_avg_empty">
+                <output-dir compare="AST">scalar_avg_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_avg_null">
+                <output-dir compare="AST">scalar_avg_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_count">
+                <output-dir compare="AST">scalar_count</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_count_empty">
+                <output-dir compare="AST">scalar_count_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_count_null">
+                <output-dir compare="AST">scalar_count_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_max">
+                <output-dir compare="AST">scalar_max</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_max_empty">
+                <output-dir compare="AST">scalar_max_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_max_null">
+                <output-dir compare="AST">scalar_max_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_min">
+                <output-dir compare="AST">scalar_min</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_min_empty">
+                <output-dir compare="AST">scalar_min_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_min_null">
+                <output-dir compare="AST">scalar_min_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_sum">
+                <output-dir compare="AST">scalar_sum</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_sum_empty">
+                <output-dir compare="AST">scalar_sum_empty</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="scalar_sum_null">
+                <output-dir compare="AST">scalar_sum_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_double">
+                <output-dir compare="AST">sum_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_double_null">
+                <output-dir compare="AST">sum_double_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_empty_01">
+                <output-dir compare="AST">sum_empty_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_empty_02">
+                <output-dir compare="AST">sum_empty_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_float">
+                <output-dir compare="AST">sum_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_float_null">
+                <output-dir compare="AST">sum_float_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int16">
+                <output-dir compare="AST">sum_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int16_null">
+                <output-dir compare="AST">sum_int16_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int32">
+                <output-dir compare="AST">sum_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int32_null">
+                <output-dir compare="AST">sum_int32_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int64">
+                <output-dir compare="AST">sum_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int64_null">
+                <output-dir compare="AST">sum_int64_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int8">
+                <output-dir compare="AST">sum_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_int8_null">
+                <output-dir compare="AST">sum_int8_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_null-with-pred">
+                <output-dir compare="AST">sum_null-with-pred</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="aggregate-sql">
+            <compilation-unit name="sum_numeric_null">
+                <output-dir compare="AST">sum_numeric_null</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="boolean">
+        <test-case FilePath="boolean">
+            <compilation-unit name="and_01">
+                <output-dir compare="AST">and_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="boolean">
+            <compilation-unit name="and_null">
+                <output-dir compare="AST">and_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="boolean">
+            <compilation-unit name="and_null_false">
+                <output-dir compare="AST">and_null_false</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="boolean">
+            <compilation-unit name="not_01">
+                <output-dir compare="AST">not_01</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="comparison">
+        <test-case FilePath="comparison">
+            <compilation-unit name="year_month_duration_order">
+                <output-dir compare="AST">year_month_duration_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="datetime_order">
+                <output-dir compare="AST">datetime_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="datetime_range">
+                <output-dir compare="AST">datetime_range</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="datetime_tzeq">
+                <output-dir compare="AST">datetime_tzeq</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="double">
+                <output-dir compare="AST">double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="double_gte_01">
+                <output-dir compare="AST">double_gte_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="double_null">
+                <output-dir compare="AST">double_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="eq_01">
+                <output-dir compare="AST">eq_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="float">
+                <output-dir compare="AST">float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="float_null">
+                <output-dir compare="AST">float_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="gt_01">
+                <output-dir compare="AST">gt_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="gte_01">
+                <output-dir compare="AST">gte_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int16">
+                <output-dir compare="AST">int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int16_null">
+                <output-dir compare="AST">int16_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int32">
+                <output-dir compare="AST">int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int32_null">
+                <output-dir compare="AST">int32_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int64">
+                <output-dir compare="AST">int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int64_null">
+                <output-dir compare="AST">int64_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int8">
+                <output-dir compare="AST">int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int8_null">
+                <output-dir compare="AST">int8_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="lt_01">
+                <output-dir compare="AST">lt_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="lte_01">
+                <output-dir compare="AST">lte_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="neq_01">
+                <output-dir compare="AST">neq_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="comparison">
+          <compilation-unit name="numeric-comparison_01">
+            <output-dir compare="AST">numeric-comparison_01</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="comparison">
+            <compilation-unit name="string">
+                <output-dir compare="AST">string</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="string_null">
+                <output-dir compare="AST">string_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_equality">
+                <output-dir compare="AST">issue363_equality</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_duration">
+                <output-dir compare="AST">issue363_inequality_duration</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_interval">
+                <output-dir compare="AST">issue363_inequality_interval</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_point">
+                <output-dir compare="AST">issue363_inequality_point</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_line">
+                <output-dir compare="AST">issue363_inequality_line</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_polygon">
+                <output-dir compare="AST">issue363_inequality_polygon</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_rectangle">
+                <output-dir compare="AST">issue363_inequality_rectangle</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_circle">
+                <output-dir compare="AST">issue363_inequality_circle</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="binary">
+                <output-dir compare="AST">binary</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="binary_null">
+                <output-dir compare="AST">binary_null</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="constructor">
+        <test-case FilePath="constructor">
+            <compilation-unit name="binary_01">
+                <output-dir compare="AST">binary_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="add-null">
+                <output-dir compare="AST">add-null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="boolean_01">
+                <output-dir compare="AST">boolean_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="circle_01">
+                <output-dir compare="AST">circle_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="date_01">
+                <output-dir compare="AST">date_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="datetime_01">
+                <output-dir compare="AST">datetime_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="double_01">
+                <output-dir compare="AST">double_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="duration_01">
+                <output-dir compare="AST">duration_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="duration_02">
+                <output-dir compare="AST">duration_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="float_01">
+                <output-dir compare="AST">float_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="int_01">
+                <output-dir compare="AST">int_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="interval">
+                <output-dir compare="AST">interval</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="line_01">
+                <output-dir compare="AST">line_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="rectangle_01">
+                <output-dir compare="AST">rectangle_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="point_01">
+                <output-dir compare="AST">point_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="polygon_01">
+                <output-dir compare="AST">polygon_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="primitive-01">
+                <output-dir compare="AST">primitive-01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="primitive-02">
+                <output-dir compare="AST">primitive-02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="primitive-03">
+                <output-dir compare="AST">primitive-03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="primitive-04">
+                <output-dir compare="AST">primitive-04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="string_01">
+                <output-dir compare="AST">string_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="time_01">
+                <output-dir compare="AST">time_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="uuid_01">
+                <output-dir compare="AST">uuid_01</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="custord">
+        <!--
+    <test-case FilePath="custord">
+      <compilation-unit name="co">
+        <output-dir compare="AST">co</output-dir>
+      </compilation-unit>
+    </test-case>
+    -->
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_01">
+                <output-dir compare="AST">customer_q_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_02">
+                <output-dir compare="AST">customer_q_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_03">
+                <output-dir compare="AST">customer_q_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_04">
+                <output-dir compare="AST">customer_q_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_05">
+                <output-dir compare="AST">customer_q_05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_06">
+                <output-dir compare="AST">customer_q_06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_07">
+                <output-dir compare="AST">customer_q_07</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="customer_q_08">
+                <output-dir compare="AST">customer_q_08</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="custord">
+          <compilation-unit name="denorm-cust-order_01">
+            <output-dir compare="AST">denorm-cust-order_01</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="custord">
+            <compilation-unit name="denorm-cust-order_02">
+                <output-dir compare="AST">denorm-cust-order_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="custord">
+          <compilation-unit name="denorm-cust-order_03">
+            <output-dir compare="AST">denorm-cust-order_03</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="custord">
+          <compilation-unit name="freq-clerk">
+            <output-dir compare="AST">freq-clerk</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="custord">
+            <compilation-unit name="join_q_01">
+                <output-dir compare="AST">join_q_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="join_q_02">
+                <output-dir compare="AST">join_q_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="join_q_03">
+                <output-dir compare="AST">join_q_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="join_q_04">
+                <output-dir compare="AST">join_q_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="load-test">
+                <output-dir compare="AST">load-test</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="order_q_01">
+                <output-dir compare="AST">order_q_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="order_q_02">
+                <output-dir compare="AST">order_q_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="order_q_03">
+                <output-dir compare="AST">order_q_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="order_q_04">
+                <output-dir compare="AST">order_q_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="order_q_05">
+                <output-dir compare="AST">order_q_05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="custord">
+            <compilation-unit name="order_q_06">
+                <output-dir compare="AST">order_q_06</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="dapd">
+        <test-case FilePath="dapd">
+            <compilation-unit name="q1">
+                <output-dir compare="AST">q1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dapd">
+            <compilation-unit name="q2">
+                <output-dir compare="AST">q2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="dapd">
+          <compilation-unit name="q3">
+            <output-dir compare="AST">q3</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+    </test-group>
+    <test-group name="dml">
+        <test-case FilePath="dml">
+            <compilation-unit name="compact-dataset-and-its-indexes">
+                <output-dir compare="AST">compact-dataset-and-its-indexes</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="using-constant-merge-policy">
+                <output-dir compare="AST">using-constant-merge-policy</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="using-prefix-merge-policy">
+                <output-dir compare="AST">using-prefix-merge-policy</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="using-correlated-prefix-merge-policy">
+                <output-dir compare="AST">using-correlated-prefix-merge-policy</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="using-no-merge-policy">
+                <output-dir compare="AST">using-no-merge-policy</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="query-issue382">
+                <output-dir compare="AST">query-issue382</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="query-issue433">
+                <output-dir compare="AST">query-issue433</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="query-issue288">
+                <output-dir compare="AST">query-issue288</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="query-issue205">
+                <output-dir compare="AST">query-issue205</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="delete-from-loaded-dataset-with-index">
+                <output-dir compare="AST">delete-from-loaded-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="delete-from-loaded-dataset">
+                <output-dir compare="AST">delete-from-loaded-dataset</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="delete-syntax-change">
+                <output-dir compare="AST">delete-syntax-change</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="drop-empty-secondary-indexes">
+                <output-dir compare="AST">drop-empty-secondary-indexes</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="drop-index">
+                <output-dir compare="AST">drop-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="create-drop-cltype">
+                <output-dir compare="AST">create-drop-cltype</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="create-drop-opntype">
+                <output-dir compare="AST">create-drop-opntype</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="empty-load-with-index">
+                <output-dir compare="AST">empty-load-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-into-empty-dataset">
+                <output-dir compare="AST">insert-into-empty-dataset</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-into-empty-dataset-with-index">
+                <output-dir compare="AST">insert-into-empty-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-syntax">
+                <output-dir compare="AST">insert-syntax</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-and-scan-dataset">
+                <output-dir compare="AST">insert-and-scan-dataset</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-and-scan-dataset-with-index">
+                <output-dir compare="AST">insert-and-scan-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-and-scan-joined-datasets">
+                <output-dir compare="AST">insert-and-scan-joined-datasets</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-into-loaded-dataset-with-index_01">
+                <output-dir compare="AST">insert-into-loaded-dataset-with-index_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-into-loaded-dataset-with-index_02">
+                <output-dir compare="AST">insert-into-loaded-dataset-with-index_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-into-loaded-dataset_01">
+                <output-dir compare="AST">insert-into-loaded-dataset_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-into-loaded-dataset_02">
+                <output-dir compare="AST">insert-into-loaded-dataset_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-src-dst-01">
+                <output-dir compare="AST">insert-src-dst-01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert">
+                <output-dir compare="AST">insert</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-duplicated-keys">
+                <output-dir compare="AST">insert-duplicated-keys</output-dir>
+                <expected-error>org.apache.hyracks.storage.am.common.exceptions.TreeIndexDuplicateKeyException
+                </expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert_less_nc">
+                <output-dir compare="AST">insert_less_nc</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="dml">
+          <compilation-unit name="load-from-hdfs">
+            <output-dir compare="AST">load-from-hdfs</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-with-autogenerated-pk_adm_01">
+                <output-dir compare="AST">insert-with-autogenerated-pk_adm_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-with-autogenerated-pk_adm_02">
+                <output-dir compare="AST">insert-with-autogenerated-pk_adm_02</output-dir>
+                <expected-error>org.apache.asterix.runtime.operators.file.ADMDataParser.ParseException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="insert-with-autogenerated-pk_adm_03">
+                <output-dir compare="AST">insert-with-autogenerated-pk_adm_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_txt_01">
+                <output-dir compare="AST">load-with-autogenerated-pk_txt_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_adm_01">
+                <output-dir compare="AST">load-with-autogenerated-pk_adm_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_adm_02">
+                <output-dir compare="AST">load-with-autogenerated-pk_adm_02</output-dir>
+                <expected-error>org.apache.asterix.runtime.operators.file.ADMDataParser.ParseException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_adm_03">
+                <output-dir compare="AST">load-with-autogenerated-pk_adm_03</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_adm_04">
+                <output-dir compare="AST">load-with-autogenerated-pk_adm_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_csv_01">
+                <output-dir compare="AST">load-with-autogenerated-pk_csv_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-autogenerated-pk_csv_02">
+                <output-dir compare="AST">load-with-autogenerated-pk_csv_02</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-index">
+                <output-dir compare="AST">load-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-ngram-index">
+                <output-dir compare="AST">load-with-ngram-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-rtree-index">
+                <output-dir compare="AST">load-with-rtree-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-word-index">
+                <output-dir compare="AST">load-with-word-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-c2o-recursive">
+                <output-dir compare="AST">opentype-c2o-recursive</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-c2o">
+                <output-dir compare="AST">opentype-c2o</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-closed-optional">
+                <output-dir compare="AST">opentype-closed-optional</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-insert">
+                <output-dir compare="AST">opentype-insert</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-insert2">
+                <output-dir compare="AST">opentype-insert2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-noexpand">
+                <output-dir compare="AST">opentype-noexpand</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-o2c-recursive">
+                <output-dir compare="AST">opentype-o2c-recursive</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-o2c">
+                <output-dir compare="AST">opentype-o2c</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="opentype-o2o">
+                <output-dir compare="AST">opentype-o2o</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-btree-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-btree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-rtree-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-rtree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-rtree-secondary-index">
+                <output-dir compare="AST">scan-delete-rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-btree-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-btree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-rtree-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-rtree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-rtree-secondary-index">
+                <output-dir compare="AST">scan-insert-rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-inverted-index-ngram-secondary-index">
+                <output-dir compare="AST">scan-insert-inverted-index-ngram-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-inverted-index-word-secondary-index">
+                <output-dir compare="AST">scan-insert-inverted-index-word-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-inverted-index-ngram-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-inverted-index-ngram-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-inverted-index-word-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-inverted-index-word-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-inverted-index-ngram-secondary-index">
+                <output-dir compare="AST">scan-delete-inverted-index-ngram-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-inverted-index-word-secondary-index">
+                <output-dir compare="AST">scan-delete-inverted-index-word-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-inverted-index-ngram-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-inverted-index-ngram-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-inverted-index-word-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-inverted-index-word-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-index-open">
+                <output-dir compare="AST">load-with-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-ngram-index-open">
+                <output-dir compare="AST">load-with-ngram-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-rtree-index-open">
+                <output-dir compare="AST">load-with-rtree-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="load-with-word-index-open">
+                <output-dir compare="AST">load-with-word-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-btree-secondary-index-open">
+                <output-dir compare="AST">scan-delete-btree-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-inverted-index-ngram-secondary-index-open">
+                <output-dir compare="AST">scan-delete-inverted-index-ngram-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-inverted-index-word-secondary-index-open">
+                <output-dir compare="AST">scan-delete-inverted-index-word-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-delete-rtree-secondary-index-open">
+                <output-dir compare="AST">scan-delete-rtree-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-btree-secondary-index-open">
+                <output-dir compare="AST">scan-insert-btree-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-inverted-index-ngram-secondary-index-open">
+                <output-dir compare="AST">scan-insert-inverted-index-ngram-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-inverted-index-word-secondary-index-open">
+                <output-dir compare="AST">scan-insert-inverted-index-word-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="scan-insert-rtree-secondary-index-open">
+                <output-dir compare="AST">scan-insert-rtree-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="dml">
+            <compilation-unit name="delete-multi-statement">
+                <output-dir compare="AST">delete-multi-statement</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="employee">
+        <test-case FilePath="employee">
+            <compilation-unit name="q_01">
+                <output-dir compare="AST">q_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="employee">
+            <compilation-unit name="q_02">
+                <output-dir compare="AST">q_02</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="failure">
+        <!--
+        <test-case FilePath="failure">
+          <compilation-unit name="q1_pricing_summary_report_failure">
+            <output-dir compare="AST">q1_pricing_summary_report_failure</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+    </test-group>
+    <!--
+    <test-group name="flwor">
+      <test-case FilePath="flwor">
+        <compilation-unit name="for01">
+          <output-dir compare="AST">for01</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for02">
+          <output-dir compare="AST">for02</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for03">
+          <output-dir compare="AST">for03</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for04">
+          <output-dir compare="AST">for04</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for05">
+          <output-dir compare="AST">for05</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for06">
+          <output-dir compare="AST">for06</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for07">
+          <output-dir compare="AST">for07</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for08">
+          <output-dir compare="AST">for08</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for09">
+          <output-dir compare="AST">for09</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for10">
+          <output-dir compare="AST">for10</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for11">
+          <output-dir compare="AST">for11</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for12">
+          <output-dir compare="AST">for12</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for13">
+          <output-dir compare="AST">for13</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for14">
+          <output-dir compare="AST">for14</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for15">
+          <output-dir compare="AST">for15</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for16">
+          <output-dir compare="AST">for16</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for17">
+          <output-dir compare="AST">for17</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for18">
+          <output-dir compare="AST">for18</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="for19">
+          <output-dir compare="AST">for19</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="grpby01">
+          <output-dir compare="AST">grpby01</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="grpby02">
+          <output-dir compare="AST">grpby02</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let01">
+          <output-dir compare="AST">let01</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let02">
+          <output-dir compare="AST">let02</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let03">
+          <output-dir compare="AST">let03</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let04">
+          <output-dir compare="AST">let04</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let05">
+          <output-dir compare="AST">let05</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let06">
+          <output-dir compare="AST">let06</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let07">
+          <output-dir compare="AST">let07</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let08">
+          <output-dir compare="AST">let08</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let09">
+          <output-dir compare="AST">let09</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let10">
+          <output-dir compare="AST">let10</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let11">
+          <output-dir compare="AST">let11</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let12">
+          <output-dir compare="AST">let12</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let13">
+          <output-dir compare="AST">let13</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let14">
+          <output-dir compare="AST">let14</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let15">
+          <output-dir compare="AST">let15</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let16">
+          <output-dir compare="AST">let16</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let17">
+          <output-dir compare="AST">let17</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let18">
+          <output-dir compare="AST">let18</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let19">
+          <output-dir compare="AST">let19</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let20">
+          <output-dir compare="AST">let20</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let21">
+          <output-dir compare="AST">let21</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let22">
+          <output-dir compare="AST">let22</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let23">
+          <output-dir compare="AST">let23</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let24">
+          <output-dir compare="AST">let24</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let25">
+          <output-dir compare="AST">let25</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let26">
+          <output-dir compare="AST">let26</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let27">
+          <output-dir compare="AST">let27</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let28">
+          <output-dir compare="AST">let28</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let29">
+          <output-dir compare="AST">let29</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let30">
+          <output-dir compare="AST">let30</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let31">
+          <output-dir compare="AST">let31</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="let32">
+          <output-dir compare="AST">let32</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-01">
+          <output-dir compare="AST">order-by-01</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-02">
+          <output-dir compare="AST">order-by-02</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-03">
+          <output-dir compare="AST">order-by-03</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-04">
+          <output-dir compare="AST">order-by-04</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-05">
+          <output-dir compare="AST">order-by-05</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-06">
+          <output-dir compare="AST">order-by-06</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-07">
+          <output-dir compare="AST">order-by-07</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-08">
+          <output-dir compare="AST">order-by-08</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-09">
+          <output-dir compare="AST">order-by-09</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-10">
+          <output-dir compare="AST">order-by-10</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-11">
+          <output-dir compare="AST">order-by-11</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="order-by-12">
+          <output-dir compare="AST">order-by-12</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-01">
+          <output-dir compare="AST">ret-01</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-02">
+          <output-dir compare="AST">ret-02</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-03">
+          <output-dir compare="AST">ret-03</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-04">
+          <output-dir compare="AST">ret-04</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-05">
+          <output-dir compare="AST">ret-05</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-06">
+          <output-dir compare="AST">ret-06</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-07">
+          <output-dir compare="AST">ret-07</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-08">
+          <output-dir compare="AST">ret-08</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-09">
+          <output-dir compare="AST">ret-09</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-10">
+          <output-dir compare="AST">ret-10</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-11">
+          <output-dir compare="AST">ret-11</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-12">
+          <output-dir compare="AST">ret-12</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-13">
+          <output-dir compare="AST">ret-13</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-14">
+          <output-dir compare="AST">ret-14</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-15">
+          <output-dir compare="AST">ret-15</output-dir>
+        </compilation-unit>
+      </test-case>
+    </test-group>
+    <test-group name="writers">
+      <test-case FilePath="writers">
+        <compilation-unit name="print_01">
+          <output-dir compare="AST">print_01</output-dir>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-16">
+          <output-dir compare="AST">ret-16</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-17">
+          <output-dir compare="AST">ret-17</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-18">
+          <output-dir compare="AST">ret-18</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="flwor">
+        <compilation-unit name="ret-19">
+          <output-dir compare="AST">ret-19</output-dir>
+        </compilation-unit>
+      </test-case>
+    </test-group>
+    -->
+    <test-group name="fuzzyjoin">
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-1_1">
+                <output-dir compare="AST">dblp-1_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-1_2.1.1">
+                <output-dir compare="AST">dblp-1_2.1.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-1_2.1">
+                <output-dir compare="AST">dblp-1_2.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-1_2">
+                <output-dir compare="AST">dblp-1_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2.1_5.3.1">
+                <output-dir compare="AST">dblp-2.1_5.3.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_1">
+                <output-dir compare="AST">dblp-2_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_2">
+                <output-dir compare="AST">dblp-2_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2.2">
+                <output-dir compare="AST">dblp-2.2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_3">
+                <output-dir compare="AST">dblp-2_3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_4">
+                <output-dir compare="AST">dblp-2_4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_5.1">
+                <output-dir compare="AST">dblp-2_5.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_5.2">
+                <output-dir compare="AST">dblp-2_5.2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_5.3.1">
+                <output-dir compare="AST">dblp-2_5.3.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_5.3">
+                <output-dir compare="AST">dblp-2_5.3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-2_5">
+                <output-dir compare="AST">dblp-2_5</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-3_1.1">
+                <output-dir compare="AST">dblp-3_1.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-3_1.2">
+                <output-dir compare="AST">dblp-3_1.2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-3_1">
+                <output-dir compare="AST">dblp-3_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-aqlplus_1">
+                <output-dir compare="AST">dblp-aqlplus_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-aqlplus_2">
+                <output-dir compare="AST">dblp-aqlplus_2</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_1">
+                <output-dir compare="AST">dblp-csx-2_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_2">
+                <output-dir compare="AST">dblp-csx-2_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_3">
+                <output-dir compare="AST">dblp-csx-2_3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_4">
+                <output-dir compare="AST">dblp-csx-2_4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_5.1">
+                <output-dir compare="AST">dblp-csx-2_5.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_5.2">
+                <output-dir compare="AST">dblp-csx-2_5.2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_5.3.1">
+                <output-dir compare="AST">dblp-csx-2_5.3.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_5.3">
+                <output-dir compare="AST">dblp-csx-2_5.3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-2_5">
+                <output-dir compare="AST">dblp-csx-2_5</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_1">
+                <output-dir compare="AST">dblp-csx-3_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_2">
+                <output-dir compare="AST">dblp-csx-3_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_3">
+                <output-dir compare="AST">dblp-csx-3_3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_4">
+                <output-dir compare="AST">dblp-csx-3_4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5.1">
+                <output-dir compare="AST">dblp-csx-3_5.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5.2">
+                <output-dir compare="AST">dblp-csx-3_5.2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5.3.1">
+                <output-dir compare="AST">dblp-csx-3_5.3.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5.3">
+                <output-dir compare="AST">dblp-csx-3_5.3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5.4.1">
+                <output-dir compare="AST">dblp-csx-3_5.4.1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5.4">
+                <output-dir compare="AST">dblp-csx-3_5.4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-3_5">
+                <output-dir compare="AST">dblp-csx-3_5</output-dir>
+            </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-aqlplus_1">
+                <output-dir compare="AST">dblp-csx-aqlplus_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-aqlplus_2">
+                <output-dir compare="AST">dblp-csx-aqlplus_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-aqlplus_3">
+                <output-dir compare="AST">dblp-csx-aqlplus_3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-csx-dblp-aqlplus_1">
+                <output-dir compare="AST">dblp-csx-dblp-aqlplus_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="dblp-lookup_1">
+                <output-dir compare="AST">dblp-lookup_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="fuzzyjoin">
+          <compilation-unit name="dblp-splits-3_1">
+            <output-dir compare="AST">dblp-splits-3_1</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="fuzzyjoin">
+            <compilation-unit name="opentype">
+                <output-dir compare="AST">opentype</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <!-- <test-group name="graph">
+        <test-case FilePath="graph">
+            <compilation-unit name="pregel-q01">
+                <output-dir compare="AST">pregel-q01</output-dir>
+            </compilation-unit>
+            <test-case FilePath="graph">
+            <compilation-unit name="pregel-q02">
+                <output-dir compare="AST">pregel-q02</output-dir>
+            </compilation-unit>
+            <test-case FilePath="graph">
+            <compilation-unit name="pregel-q03">
+                <output-dir compare="AST">pregel-q03</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group> -->
+    <test-group name="index-join">
+        <test-case FilePath="index-join">
+            <compilation-unit name="btree-index-nested-loop-join">
+                <output-dir compare="AST">btree-index-nested-loop-join</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-join">
+            <compilation-unit name="btree-primary-equi-join">
+                <output-dir compare="AST">btree-primary-equi-join</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-join">
+            <compilation-unit name="btree-secondary-equi-join_01">
+                <output-dir compare="AST">btree-secondary-equi-join_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-join">
+            <compilation-unit name="btree-secondary-equi-join_02">
+                <output-dir compare="AST">btree-secondary-equi-join_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-join">
+            <compilation-unit name="btree-secondary-equi-join_03">
+                <output-dir compare="AST">btree-secondary-equi-join_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-join">
+            <compilation-unit name="rtree-spatial-intersect-point">
+                <output-dir compare="AST">rtree-spatial-intersect-point</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="index-selection">
+        <test-case FilePath="index-selection">
+            <compilation-unit name="btree-index-composite-key">
+                <output-dir compare="AST">btree-index-composite-key</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="btree-index-composite-key-mixed-intervals">
+                <output-dir compare="AST">btree-index-composite-key-mixed-intervals</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="btree-index-rewrite-multiple">
+                <output-dir compare="AST">btree-index-rewrite-multiple</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="cust-index-age-nullable">
+                <output-dir compare="AST">cust-index-age-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ngram-contains">
+                <output-dir compare="AST">inverted-index-ngram-contains</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ngram-edit-distance-panic">
+                <output-dir compare="AST">inverted-index-ngram-edit-distance-panic</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ngram-edit-distance">
+                <output-dir compare="AST">inverted-index-ngram-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ngram-edit-distance-word-tokens">
+                <output-dir compare="AST">inverted-index-ngram-edit-distance-word-tokens</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ngram-jaccard">
+                <output-dir compare="AST">inverted-index-ngram-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ngram-edit-distance-contains">
+                <output-dir compare="AST">inverted-index-ngram-edit-distance-contains</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-olist-edit-distance-panic">
+                <output-dir compare="AST">inverted-index-olist-edit-distance-panic</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-olist-edit-distance">
+                <output-dir compare="AST">inverted-index-olist-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-olist-jaccard">
+                <output-dir compare="AST">inverted-index-olist-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-ulist-jaccard">
+                <output-dir compare="AST">inverted-index-ulist-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-word-contains">
+                <output-dir compare="AST">inverted-index-word-contains</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="inverted-index-word-jaccard">
+                <output-dir compare="AST">inverted-index-word-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="orders-index-custkey-conjunctive-open">
+                <output-dir compare="AST">orders-index-custkey-conjunctive-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="orders-index-custkey-conjunctive">
+                <output-dir compare="AST">orders-index-custkey-conjunctive</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="orders-index-custkey-open">
+                <output-dir compare="AST">orders-index-custkey-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="orders-index-custkey">
+                <output-dir compare="AST">orders-index-custkey</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="range-search-open">
+                <output-dir compare="AST">range-search-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="range-search">
+                <output-dir compare="AST">range-search</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="rtree-secondary-index-nullable">
+                <output-dir compare="AST">rtree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="rtree-secondary-index-open">
+                <output-dir compare="AST">rtree-secondary-index-open</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="rtree-secondary-index">
+                <output-dir compare="AST">rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="rtree-secondary-index-circular-query">
+                <output-dir compare="AST">rtree-secondary-index-circular-query</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-selection">
+            <compilation-unit name="disjunctive-predicate-1">
+                <output-dir compare="AST">disjunctive-predicate-1</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="inverted-index-join">
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="ngram-edit-distance">
+                <output-dir compare="AST">ngram-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="ngram-edit-distance-inline">
+                <output-dir compare="AST">ngram-edit-distance-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="ngram-jaccard">
+                <output-dir compare="AST">ngram-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="ngram-jaccard-inline">
+                <output-dir compare="AST">ngram-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="olist-edit-distance">
+                <output-dir compare="AST">olist-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="olist-edit-distance-inline">
+                <output-dir compare="AST">olist-edit-distance-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="olist-jaccard">
+                <output-dir compare="AST">olist-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="olist-jaccard-inline">
+                <output-dir compare="AST">olist-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="ulist-jaccard">
+                <output-dir compare="AST">ulist-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="ulist-jaccard-inline">
+                <output-dir compare="AST">ulist-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="word-jaccard">
+                <output-dir compare="AST">word-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join">
+            <compilation-unit name="word-jaccard-inline">
+                <output-dir compare="AST">word-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="inverted-index-join-noeqjoin">
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="ngram-edit-distance">
+                <output-dir compare="AST">ngram-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="ngram-edit-distance-inline">
+                <output-dir compare="AST">ngram-edit-distance-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="ngram-jaccard">
+                <output-dir compare="AST">ngram-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="ngram-jaccard-inline">
+                <output-dir compare="AST">ngram-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="olist-edit-distance">
+                <output-dir compare="AST">olist-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="olist-edit-distance-inline">
+                <output-dir compare="AST">olist-edit-distance-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="olist-jaccard">
+                <output-dir compare="AST">olist-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="olist-jaccard-inline">
+                <output-dir compare="AST">olist-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="ulist-jaccard">
+                <output-dir compare="AST">ulist-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="ulist-jaccard-inline">
+                <output-dir compare="AST">ulist-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="word-jaccard">
+                <output-dir compare="AST">word-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="inverted-index-join-noeqjoin">
+            <compilation-unit name="word-jaccard-inline">
+                <output-dir compare="AST">word-jaccard-inline</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="list">
+        <test-case FilePath="list">
+            <compilation-unit name="any-collection-member_01">
+                <output-dir compare="AST">any-collection-member_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="get-item_01">
+                <output-dir compare="AST">get-item_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="get-item_02">
+                <output-dir compare="AST">get-item_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="len_01">
+                <output-dir compare="AST">len_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="len_null_01">
+                <output-dir compare="AST">len_null_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="listify_01">
+                <output-dir compare="AST">listify_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="listify_02">
+                <output-dir compare="AST">listify_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="listify_03">
+                <output-dir compare="AST">listify_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="ordered-list-constructor_01">
+                <output-dir compare="AST">ordered-list-constructor_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="ordered-list-constructor_02">
+                <output-dir compare="AST">ordered-list-constructor_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="ordered-list-constructor_03">
+                <output-dir compare="AST">ordered-list-constructor_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="scan-collection_01">
+                <output-dir compare="AST">scan-collection_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--         <test-case FilePath="list">
+                    <compilation-unit name="union_01">
+                        <output-dir compare="AST">union_01</output-dir>
+                    </compilation-unit>
+                </test-case>
+                <test-case FilePath="list">
+                    <compilation-unit name="union_02">
+                        <output-dir compare="AST">union_02</output-dir>
+                    </compilation-unit>
+                </test-case>
+         -->
+        <test-case FilePath="list">
+            <compilation-unit name="unordered-list-constructor_01">
+                <output-dir compare="AST">unordered-list-constructor_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="unordered-list-constructor_02">
+                <output-dir compare="AST">unordered-list-constructor_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="unordered-list-constructor_03">
+                <output-dir compare="AST">unordered-list-constructor_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="list">
+            <compilation-unit name="query-issue428">
+                <output-dir compare="AST">query-issue428</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="misc">
+        <test-case FilePath="misc">
+            <compilation-unit name="partition-by-nonexistent-field">
+                <output-dir compare="AST">partition-by-nonexistent-field</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="float_01">
+                <output-dir compare="AST">float_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="flushtest">
+                <output-dir compare="AST">flushtest</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="groupby-orderby-count">
+                <output-dir compare="AST">groupby-orderby-count</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="ifthenelse_01">
+                <output-dir compare="AST">ifthenelse_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="is-null_01">
+                <output-dir compare="AST">is-null_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="nested-loop-join_01">
+                <output-dir compare="AST">nested-loop-join_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="query_issue267">
+                <output-dir compare="AST">query_issue267</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="stable_sort">
+                <output-dir compare="AST">stable_sort</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+         <test-case FilePath="misc">
+           <compilation-unit name="range_01">
+             <output-dir compare="AST">range_01</output-dir>
+           </compilation-unit>
+         </test-case>
+        -->
+        <!--
+          <test-case FilePath="misc">
+            <compilation-unit name="tid_01">
+              <output-dir compare="AST">tid_01</output-dir>
+            </compilation-unit>
+          </test-case>
+         -->
+        <test-case FilePath="misc">
+            <compilation-unit name="year_01">
+                <output-dir compare="AST">year_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="string_eq_01">
+                <output-dir compare="AST">string_eq_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="misc">
+            <compilation-unit name="prefix-search">
+                <output-dir compare="AST">prefix-search</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="open-index-enforced">
+        <test-group FilePath="open-index-enforced/error-checking">
+            <test-case FilePath="open-index-enforced/error-checking">
+                <compilation-unit name="enforced-field-name-collision">
+                    <output-dir compare="AST">enforced-field-name-collision</output-dir>
+                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException
+                    </expected-error>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/error-checking">
+                <compilation-unit name="enforced-field-type-collision">
+                    <output-dir compare="AST">enforced-field-type-collision</output-dir>
+                    <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/error-checking">
+                <compilation-unit name="missing-enforce-statement">
+                    <output-dir compare="AST">missing-enforce-statement</output-dir>
+                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException
+                    </expected-error>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/error-checking">
+                <compilation-unit name="index-on-closed-type">
+                    <output-dir compare="AST">index-on-closed-type</output-dir>
+                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException
+                    </expected-error>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="open-index-enforced/index-join">
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="btree-secondary-equi-join">
+                    <output-dir compare="AST">btree-secondary-equi-join</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="ngram-edit-distance">
+                    <output-dir compare="AST">ngram-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="ngram-edit-distance-inline">
+                    <output-dir compare="AST">ngram-edit-distance-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="ngram-jaccard">
+                    <output-dir compare="AST">ngram-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="ngram-jaccard-inline">
+                    <output-dir compare="AST">ngram-jaccard-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="rtree-spatial-intersect-point">
+                    <output-dir compare="AST">rtree-spatial-intersect-point</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="word-jaccard">
+                    <output-dir compare="AST">word-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-join">
+                <compilation-unit name="word-jaccard-inline">
+                    <output-dir compare="AST">word-jaccard-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="open-index-enforced/index-leftouterjoin">
+            <test-case FilePath="open-index-enforced/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-btree-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-btree-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-btree-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-btree-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-invidx-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-invidx-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-invidx-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-invidx-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-rtree-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-rtree-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-rtree-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-rtree-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="open-index-enforced/index-selection">
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="btree-index-composite-key">
+                    <output-dir compare="AST">btree-index-composite-key</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="btree-index-composite-key-mixed-intervals">
+                    <output-dir compare="AST">btree-index-composite-key-mixed-intervals</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="btree-index-rewrite-multiple">
+                    <output-dir compare="AST">btree-index-rewrite-multiple</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-ngram-contains">
+                    <output-dir compare="AST">inverted-index-ngram-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-contains">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-panic">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-panic</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-word-tokens">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-word-tokens</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-ngram-jaccard">
+                    <output-dir compare="AST">inverted-index-ngram-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-word-contains">
+                    <output-dir compare="AST">inverted-index-word-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="inverted-index-word-jaccard">
+                    <output-dir compare="AST">inverted-index-word-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="orders-index-custkey">
+                    <output-dir compare="AST">orders-index-custkey</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="orders-index-custkey-conjunctive">
+                    <output-dir compare="AST">orders-index-custkey-conjunctive</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="range-search">
+                    <output-dir compare="AST">range-search</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/index-selection">
+                <compilation-unit name="rtree-secondary-index">
+                    <output-dir compare="AST">rtree-secondary-index</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group name="open-index-enforced/external-indexing">
+            <test-case FilePath="open-index-enforced/external-indexing">
+                <compilation-unit name="adm-format">
+                    <output-dir compare="AST">adm-format</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/external-indexing">
+                <compilation-unit name="rtree-index">
+                    <output-dir compare="AST">rtree-index</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/external-indexing">
+                <compilation-unit name="leftouterjoin">
+                    <output-dir compare="AST">leftouterjoin</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="open-index-enforced/external-indexing">
+                <compilation-unit name="leftouterjoin-rtree">
+                    <output-dir compare="AST">leftouterjoin-rtree</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+    </test-group>
+    <test-group name="nested-open-index">
+        <test-group FilePath="nested-open-index/index-join">
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="btree-secondary-equi-join">
+                    <output-dir compare="AST">btree-secondary-equi-join</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="ngram-edit-distance">
+                    <output-dir compare="AST">ngram-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="ngram-edit-distance-inline">
+                    <output-dir compare="AST">ngram-edit-distance-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="ngram-jaccard">
+                    <output-dir compare="AST">ngram-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="ngram-jaccard-inline">
+                    <output-dir compare="AST">ngram-jaccard-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="rtree-spatial-intersect-point">
+                    <output-dir compare="AST">rtree-spatial-intersect-point</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="word-jaccard">
+                    <output-dir compare="AST">word-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-join">
+                <compilation-unit name="word-jaccard-inline">
+                    <output-dir compare="AST">word-jaccard-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="nested-open-index/index-leftouterjoin">
+            <test-case FilePath="nested-open-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-btree-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-btree-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-btree-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-btree-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-invidx-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-invidx-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-invidx-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-invidx-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-rtree-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-rtree-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-rtree-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-rtree-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="nested-open-index/index-selection">
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="btree-index-composite-key">
+                    <output-dir compare="AST">btree-index-composite-key</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="btree-index-composite-key-mixed-intervals">
+                    <output-dir compare="AST">btree-index-composite-key-mixed-intervals</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="btree-index-rewrite-multiple">
+                    <output-dir compare="AST">btree-index-rewrite-multiple</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-contains">
+                    <output-dir compare="AST">inverted-index-ngram-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-contains">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-panic">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-panic</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-work-tokens">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-word-tokens</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-jaccard">
+                    <output-dir compare="AST">inverted-index-ngram-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-word-contains">
+                    <output-dir compare="AST">inverted-index-word-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="inverted-index-word-jaccard">
+                    <output-dir compare="AST">inverted-index-word-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="orders-index-custkey">
+                    <output-dir compare="AST">orders-index-custkey</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="orders-index-custkey-conjunctive">
+                    <output-dir compare="AST">orders-index-custkey-conjunctive</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="range-search">
+                    <output-dir compare="AST">range-search</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/index-selection">
+                <compilation-unit name="rtree-secondary-index">
+                    <output-dir compare="AST">rtree-secondary-index</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group name="nested-open-index/external-indexing">
+            <test-case FilePath="nested-open-index/external-indexing">
+                <compilation-unit name="adm-format">
+                    <output-dir compare="AST">adm-format</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/external-indexing">
+                <compilation-unit name="rtree-index">
+                    <output-dir compare="AST">rtree-index</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/external-indexing">
+                <compilation-unit name="leftouterjoin">
+                    <output-dir compare="AST">leftouterjoin</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/external-indexing">
+                <compilation-unit name="leftouterjoin-rtree">
+                    <output-dir compare="AST">leftouterjoin-rtree</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group name="nested-open-index/highly-open-highly-nested">
+            <test-case FilePath="nested-open-index/highly-open-highly-nested">
+                <compilation-unit name="bottom-closed-top-closed">
+                    <output-dir compare="AST">bottom-closed-top-closed</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/highly-open-highly-nested">
+                <compilation-unit name="bottom-closed-top-open">
+                    <output-dir compare="AST">bottom-closed-top-open</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/highly-open-highly-nested">
+                <compilation-unit name="bottom-open-top-closed">
+                    <output-dir compare="AST">bottom-open-top-closed</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-open-index/highly-open-highly-nested">
+                <compilation-unit name="bottom-open-top-open">
+                    <output-dir compare="AST">bottom-open-top-open</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+    </test-group>
+    <test-group name="nested-index">
+        <test-group FilePath="nested-index/index-join">
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="btree-primary-equi-join">
+                    <output-dir compare="AST">btree-primary-equi-join</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="btree-secondary-equi-join">
+                    <output-dir compare="AST">btree-secondary-equi-join</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="ngram-edit-distance">
+                    <output-dir compare="AST">ngram-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="ngram-edit-distance-inline">
+                    <output-dir compare="AST">ngram-edit-distance-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="ngram-jaccard">
+                    <output-dir compare="AST">ngram-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="ngram-jaccard-inline">
+                    <output-dir compare="AST">ngram-jaccard-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="rtree-spatial-intersect-point">
+                    <output-dir compare="AST">rtree-spatial-intersect-point</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="word-jaccard">
+                    <output-dir compare="AST">word-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-join">
+                <compilation-unit name="word-jaccard-inline">
+                    <output-dir compare="AST">word-jaccard-inline</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="nested-index/index-leftouterjoin">
+            <test-case FilePath="nested-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-btree-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-btree-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-btree-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-btree-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-invidx-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-invidx-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-invidx-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-invidx-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-rtree-sidx1">
+                    <output-dir compare="AST">probe-pidx-with-join-rtree-sidx1</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-leftouterjoin">
+                <compilation-unit name="probe-pidx-with-join-rtree-sidx2">
+                    <output-dir compare="AST">probe-pidx-with-join-rtree-sidx2</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group FilePath="nested-index/index-selection">
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="btree-index-composite-key">
+                    <output-dir compare="AST">btree-index-composite-key</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="btree-index-composite-key-mixed-intervals">
+                    <output-dir compare="AST">btree-index-composite-key-mixed-intervals</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="btree-index-rewrite-multiple">
+                    <output-dir compare="AST">btree-index-rewrite-multiple</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="cust-index-age-nullable">
+                    <output-dir compare="AST">cust-index-age-nullable</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-contains">
+                    <output-dir compare="AST">inverted-index-ngram-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-contains">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-panic">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-panic</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-edit-distance-word-tokens">
+                    <output-dir compare="AST">inverted-index-ngram-edit-distance-word-tokens</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ngram-jaccard">
+                    <output-dir compare="AST">inverted-index-ngram-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-olist-edit-distance">
+                    <output-dir compare="AST">inverted-index-olist-edit-distance</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-olist-edit-distance-panic">
+                    <output-dir compare="AST">inverted-index-olist-edit-distance-panic</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-olist-jaccard">
+                    <output-dir compare="AST">inverted-index-olist-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-ulist-jaccard">
+                    <output-dir compare="AST">inverted-index-ulist-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-word-contains">
+                    <output-dir compare="AST">inverted-index-word-contains</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="inverted-index-word-jaccard">
+                    <output-dir compare="AST">inverted-index-word-jaccard</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="orders-index-custkey">
+                    <output-dir compare="AST">orders-index-custkey</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="orders-index-custkey-conjunctive">
+                    <output-dir compare="AST">orders-index-custkey-conjunctive</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="orders-index-custkey-conjunctive-open">
+                    <output-dir compare="AST">orders-index-custkey-conjunctive-open</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="orders-index-custkey-open">
+                    <output-dir compare="AST">orders-index-custkey-open</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="range-search">
+                    <output-dir compare="AST">range-search</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="range-search-open">
+                    <output-dir compare="AST">range-search-open</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="rtree-secondary-index">
+                    <output-dir compare="AST">rtree-secondary-index</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="rtree-secondary-index-nullable">
+                    <output-dir compare="AST">rtree-secondary-index-nullable</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/index-selection">
+                <compilation-unit name="rtree-secondary-index-open">
+                    <output-dir compare="AST">rtree-secondary-index-open</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+        <test-group name="nested-index/external-indexing">
+            <test-case FilePath="nested-index/external-indexing">
+                <compilation-unit name="adm-format">
+                    <output-dir compare="AST">adm-format</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/external-indexing">
+                <compilation-unit name="rtree-index">
+                    <output-dir compare="AST">rtree-index</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/external-indexing">
+                <compilation-unit name="leftouterjoin">
+                    <output-dir compare="AST">leftouterjoin</output-dir>
+                </compilation-unit>
+            </test-case>
+            <test-case FilePath="nested-index/external-indexing">
+                <compilation-unit name="leftouterjoin-rtree">
+                    <output-dir compare="AST">leftouterjoin-rtree</output-dir>
+                </compilation-unit>
+            </test-case>
+        </test-group>
+    </test-group>
+    <test-group name="nested-index-dml">
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="compact-dataset-and-its-indexes">
+                <output-dir compare="AST">compact-dataset-and-its-indexes</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="nested-uuid-load">
+                <output-dir compare="AST">nested-uuid-load</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="nested-uuid-insert">
+                <output-dir compare="AST">nested-uuid-insert</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="delete-from-loaded-dataset-with-index">
+                <output-dir compare="AST">delete-from-loaded-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="drop-index">
+                <output-dir compare="AST">drop-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="insert-into-empty-dataset-with-index">
+                <output-dir compare="AST">insert-into-empty-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="insert-into-loaded-dataset-with-index_01">
+                <output-dir compare="AST">insert-into-loaded-dataset-with-index_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="insert-into-loaded-dataset-with-index_02">
+                <output-dir compare="AST">insert-into-loaded-dataset-with-index_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="load-with-index">
+                <output-dir compare="AST">load-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="load-with-ngram-index">
+                <output-dir compare="AST">load-with-ngram-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="load-with-rtree-index">
+                <output-dir compare="AST">load-with-rtree-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="load-with-word-index">
+                <output-dir compare="AST">load-with-word-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-btree-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-btree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-rtree-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-rtree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-rtree-secondary-index">
+                <output-dir compare="AST">scan-delete-rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-btree-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-btree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-rtree-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-rtree-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-rtree-secondary-index">
+                <output-dir compare="AST">scan-insert-rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-inverted-index-ngram-secondary-index">
+                <output-dir compare="AST">scan-insert-inverted-index-ngram-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-inverted-index-word-secondary-index">
+                <output-dir compare="AST">scan-insert-inverted-index-word-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-inverted-index-ngram-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-inverted-index-ngram-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-insert-inverted-index-word-secondary-index-nullable">
+                <output-dir compare="AST">scan-insert-inverted-index-word-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-inverted-index-ngram-secondary-index">
+                <output-dir compare="AST">scan-delete-inverted-index-ngram-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-inverted-index-word-secondary-index">
+                <output-dir compare="AST">scan-delete-inverted-index-word-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-inverted-index-ngram-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-inverted-index-ngram-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="nested-index-dml">
+            <compilation-unit name="scan-delete-inverted-index-word-secondary-index-nullable">
+                <output-dir compare="AST">scan-delete-inverted-index-word-secondary-index-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="nestrecords">
+        <test-case FilePath="nestrecords">
+            <compilation-unit name="nestrecord">
+                <output-dir compare="AST">nestrecord</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="numeric">
+        <test-case FilePath="numeric">
+            <compilation-unit name="caret0">
+                <output-dir compare="AST">caret0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="abs0">
+                <output-dir compare="AST">abs0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="abs1">
+                <output-dir compare="AST">abs1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="abs2">
+                <output-dir compare="AST">abs2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="abs3">
+                <output-dir compare="AST">abs3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="abs4">
+                <output-dir compare="AST">abs4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="add_double">
+                <output-dir compare="AST">add_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="add_float">
+                <output-dir compare="AST">add_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="add_int16">
+                <output-dir compare="AST">add_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="add_int32">
+                <output-dir compare="AST">add_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="add_int64">
+                <output-dir compare="AST">add_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="add_int8">
+                <output-dir compare="AST">add_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="ceiling0">
+                <output-dir compare="AST">ceiling0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="ceiling1">
+                <output-dir compare="AST">ceiling1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="ceiling2">
+                <output-dir compare="AST">ceiling2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="ceiling3">
+                <output-dir compare="AST">ceiling3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="ceiling4">
+                <output-dir compare="AST">ceiling4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="divide_double">
+                <output-dir compare="AST">divide_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="divide_float">
+                <output-dir compare="AST">divide_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="divide_int16">
+                <output-dir compare="AST">divide_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="divide_int32">
+                <output-dir compare="AST">divide_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="divide_int64">
+                <output-dir compare="AST">divide_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="divide_int8">
+                <output-dir compare="AST">divide_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="floor0">
+                <output-dir compare="AST">floor0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="floor1">
+                <output-dir compare="AST">floor1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="floor2">
+                <output-dir compare="AST">floor2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="floor3">
+                <output-dir compare="AST">floor3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="floor4">
+                <output-dir compare="AST">floor4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="multiply_double">
+                <output-dir compare="AST">multiply_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="multiply_float">
+                <output-dir compare="AST">multiply_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="multiply_int16">
+                <output-dir compare="AST">multiply_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="multiply_int32">
+                <output-dir compare="AST">multiply_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="multiply_int64">
+                <output-dir compare="AST">multiply_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="multiply_int8">
+                <output-dir compare="AST">multiply_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even0">
+                <output-dir compare="AST">round-half-to-even0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even1">
+                <output-dir compare="AST">round-half-to-even1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even2">
+                <output-dir compare="AST">round-half-to-even2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even20">
+                <output-dir compare="AST">round-half-to-even20</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even21">
+                <output-dir compare="AST">round-half-to-even21</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even22">
+                <output-dir compare="AST">round-half-to-even22</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even23">
+                <output-dir compare="AST">round-half-to-even23</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even24">
+                <output-dir compare="AST">round-half-to-even24</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even3">
+                <output-dir compare="AST">round-half-to-even3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even4">
+                <output-dir compare="AST">round-half-to-even4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round-half-to-even5">
+                <output-dir compare="AST">round-half-to-even5</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round0">
+                <output-dir compare="AST">round0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round1">
+                <output-dir compare="AST">round1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round2">
+                <output-dir compare="AST">round2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round3">
+                <output-dir compare="AST">round3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="round4">
+                <output-dir compare="AST">round4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="subtract_double">
+                <output-dir compare="AST">subtract_double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="subtract_float">
+                <output-dir compare="AST">subtract_float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="subtract_int16">
+                <output-dir compare="AST">subtract_int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="subtract_int32">
+                <output-dir compare="AST">subtract_int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="subtract_int64">
+                <output-dir compare="AST">subtract_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="subtract_int8">
+                <output-dir compare="AST">subtract_int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="unary-minus_double_02">
+                <output-dir compare="AST">unary-minus_double_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="unary-minus_float_02">
+                <output-dir compare="AST">unary-minus_float_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="unary-minus_int_02">
+                <output-dir compare="AST">unary-minus_int_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="unary-minus_null">
+                <output-dir compare="AST">unary-minus_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="numeric">
+            <compilation-unit name="query-issue355">
+                <output-dir compare="AST">query-issue355</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="open-closed">
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="c2c-w-optional">
+            <output-dir compare="AST">c2c-w-optional</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="c2c-wo-optional">
+            <output-dir compare="AST">c2c-wo-optional</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="c2c">
+            <output-dir compare="AST">c2c</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="open-closed">
+            <compilation-unit name="heterog-list-ordered01">
+                <output-dir compare="AST">heterog-list-ordered01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="heterog-list01">
+                <output-dir compare="AST">heterog-list01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="heterog-list02">
+            <output-dir compare="AST">heterog-list02</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="heterog-list03">
+            <output-dir compare="AST">heterog-list03</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-01">
+                <output-dir compare="AST">open-closed-01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-12">
+                <output-dir compare="AST">open-closed-12</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-14">
+                <output-dir compare="AST">open-closed-14</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue134">
+                <output-dir compare="AST">query-issue134</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue55">
+                <output-dir compare="AST">query-issue55</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue55-1">
+                <output-dir compare="AST">query-issue55-1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue166">
+                <output-dir compare="AST">query-issue166</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue208">
+                <output-dir compare="AST">query-issue208</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue236">
+                <output-dir compare="AST">query-issue236</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-15">
+            <output-dir compare="AST">open-closed-15</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-16">
+            <output-dir compare="AST">open-closed-16</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-17">
+            <output-dir compare="AST">open-closed-17</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-19">
+            <output-dir compare="AST">open-closed-19</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-20">
+            <output-dir compare="AST">open-closed-20</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-21">
+            <output-dir compare="AST">open-closed-21</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-22">
+            <output-dir compare="AST">open-closed-22</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-24">
+                <output-dir compare="AST">open-closed-24</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-25">
+                <output-dir compare="AST">open-closed-25</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-26">
+                <output-dir compare="AST">open-closed-26</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-28">
+            <output-dir compare="AST">open-closed-28</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-29">
+                <output-dir compare="AST">open-closed-29</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="open-closed">
+          <compilation-unit name="open-closed-30">
+            <output-dir compare="AST">open-closed-30</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-31">
+                <output-dir compare="AST">open-closed-31</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-32">
+                <output-dir compare="AST">open-closed-32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="open-closed-33">
+                <output-dir compare="AST">open-closed-33</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-proposal02">
+                <output-dir compare="AST">query-proposal02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-proposal">
+                <output-dir compare="AST">query-proposal</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue350">
+                <output-dir compare="AST">query-issue350</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue350-2">
+                <output-dir compare="AST">query-issue350-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue343">
+                <output-dir compare="AST">query-issue343</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue343-2">
+                <output-dir compare="AST">query-issue343-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue196">
+                <output-dir compare="AST">query-issue196</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue377">
+                <output-dir compare="AST">query-issue377</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue410">
+                <output-dir compare="AST">query-issue410</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue453">
+                <output-dir compare="AST">query-issue453</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue453-2">
+                <output-dir compare="AST">query-issue453-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue456">
+                <output-dir compare="AST">query-issue456</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue465">
+                <output-dir compare="AST">query-issue465</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue258">
+                <output-dir compare="AST">query-issue258</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue423">
+                <output-dir compare="AST">query-issue423</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue423-2">
+                <output-dir compare="AST">query-issue423-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue442">
+                <output-dir compare="AST">query-issue442</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue487">
+                <output-dir compare="AST">query-issue487</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue592">
+                <output-dir compare="AST">query-issue592</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="open-closed">
+            <compilation-unit name="query-issue625">
+                <output-dir compare="AST">query-issue625</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="quantifiers">
+        <test-case FilePath="quantifiers">
+            <compilation-unit name="everysat_01">
+                <output-dir compare="AST">everysat_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="quantifiers">
+          <compilation-unit name="everysat_02">
+            <output-dir compare="AST">everysat_02</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="quantifiers">
+          <compilation-unit name="everysat_03">
+            <output-dir compare="AST">everysat_03</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="quantifiers">
+            <compilation-unit name="everysat_04">
+                <output-dir compare="AST">everysat_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="quantifiers">
+            <compilation-unit name="somesat_01">
+                <output-dir compare="AST">somesat_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="quantifiers">
+            <compilation-unit name="somesat_02">
+                <output-dir compare="AST">somesat_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="quantifiers">
+          <compilation-unit name="somesat_03">
+            <output-dir compare="AST">somesat_03</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="quantifiers">
+          <compilation-unit name="somesat_04">
+            <output-dir compare="AST">somesat_04</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--
+        <test-case FilePath="quantifiers">
+          <compilation-unit name="somesat_05">
+            <output-dir compare="AST">somesat_05</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="quantifiers">
+            <compilation-unit name="somesat_06">
+                <output-dir compare="AST">somesat_06</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="range-hints">
+        <test-case FilePath="range-hints">
+            <compilation-unit name="order-by">
+                <output-dir compare="AST">order-by</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="range-hints">
+            <compilation-unit name="order-by-exception_01">
+                <output-dir compare="AST">order-by</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="range-hints">
+            <compilation-unit name="order-by-exception_02">
+                <output-dir compare="AST">order-by</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="records">
+        &RecordsQueries;
+    </test-group>
+    <test-group name="scan">
+        <test-case FilePath="scan">
+            <compilation-unit name="10">
+                <output-dir compare="AST">10</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="20">
+                <output-dir compare="AST">20</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="issue238_query_1">
+                <output-dir compare="AST">issue238_query_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="issue238_query_2">
+                <output-dir compare="AST">issue238_query_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="invalid-scan-syntax">
+                <output-dir compare="AST">invalid-scan-syntax</output-dir>
+                <expected-error>SyntaxError</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="30">
+                <output-dir compare="AST">30</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="alltypes_01">
+                <output-dir compare="AST">alltypes_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="alltypes_01">
+                <output-dir compare="AST">alltypes_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="alltypes_02">
+                <output-dir compare="AST">alltypes_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="numeric_types_01">
+                <output-dir compare="AST">numeric_types_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="scan">
+            <compilation-unit name="spatial_types_01">
+                <output-dir compare="AST">spatial_types_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="scan">
+          <compilation-unit name="spatial_types_02">
+            <output-dir compare="AST">spatial_types_02</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="scan">
+            <compilation-unit name="temp_types_01">
+                <output-dir compare="AST">temp_types_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="scan">
+          <compilation-unit name="temp_types_02">
+            <output-dir compare="AST">temp_types_02</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+    </test-group>
+    <test-group name="semistructured">
+        <test-case FilePath="semistructured">
+            <compilation-unit name="count-nullable">
+                <output-dir compare="AST">count-nullable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="semistructured">
+            <compilation-unit name="cust-filter">
+                <output-dir compare="AST">cust-filter</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="semistructured">
+            <compilation-unit name="has-param1">
+                <output-dir compare="AST">has-param1</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="similarity">
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance-check_ints">
+                <output-dir compare="AST">edit-distance-check_ints</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance-check_strings">
+                <output-dir compare="AST">edit-distance-check_strings</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance-check_unicode">
+                <output-dir compare="AST">edit-distance-check_unicode</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance-list-is-filterable">
+                <output-dir compare="AST">edit-distance-list-is-filterable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance-string-is-filterable">
+                <output-dir compare="AST">edit-distance-string-is-filterable</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance_ints">
+                <output-dir compare="AST">edit-distance_ints</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="edit-distance_strings">
+                <output-dir compare="AST">edit-distance_strings</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="fuzzyeq-edit-distance">
+                <output-dir compare="AST">fuzzyeq-edit-distance</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="fuzzyeq-similarity-jaccard">
+                <output-dir compare="AST">fuzzyeq-similarity-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="prefix-len-jaccard">
+                <output-dir compare="AST">prefix-len-jaccard</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-check_ints">
+                <output-dir compare="AST">similarity-jaccard-check_ints</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-check_query">
+                <output-dir compare="AST">similarity-jaccard-check_query</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-check_strings">
+                <output-dir compare="AST">similarity-jaccard-check_strings</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-prefix-check">
+                <output-dir compare="AST">similarity-jaccard-prefix-check</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-prefix">
+                <output-dir compare="AST">similarity-jaccard-prefix</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-sorted-check_ints">
+                <output-dir compare="AST">similarity-jaccard-sorted-check_ints</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-sorted-check_query">
+                <output-dir compare="AST">similarity-jaccard-sorted-check_query</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-sorted-check_strings">
+                <output-dir compare="AST">similarity-jaccard-sorted-check_strings</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-sorted_ints">
+                <output-dir compare="AST">similarity-jaccard-sorted_ints</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-sorted_query">
+                <output-dir compare="AST">similarity-jaccard-sorted_query</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-sorted_strings">
+                <output-dir compare="AST">similarity-jaccard-sorted_strings</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard_ints">
+                <output-dir compare="AST">similarity-jaccard_ints</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard_query">
+                <output-dir compare="AST">similarity-jaccard_query</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard_strings">
+                <output-dir compare="AST">similarity-jaccard_strings</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="similarity">
+            <compilation-unit name="similarity-jaccard-check_strings_issue628">
+                <output-dir compare="AST">similarity-jaccard-check_strings_issue628</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="spatial">
+        <test-case FilePath="spatial">
+            <compilation-unit name="cell-aggregation-with-filtering">
+                <output-dir compare="AST">cell-aggregation-with-filtering</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="cell-aggregation">
+                <output-dir compare="AST">cell-aggregation</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="circle_accessor">
+                <output-dir compare="AST">circle_accessor</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="circle-intersect-circle">
+                <output-dir compare="AST">circle-intersect-circle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="create-rtree-index">
+                <output-dir compare="AST">create-rtree-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="distance-between-points">
+                <output-dir compare="AST">distance-between-points</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="line_accessor">
+                <output-dir compare="AST">line_accessor</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="line-intersect-circle">
+                <output-dir compare="AST">line-intersect-circle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="line-intersect-line">
+                <output-dir compare="AST">line-intersect-line</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="line-intersect-polygon">
+                <output-dir compare="AST">line-intersect-polygon</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="line-intersect-rectangle">
+                <output-dir compare="AST">line-intersect-rectangle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="point_accessor">
+                <output-dir compare="AST">point_accessor</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="point-equals-point">
+                <output-dir compare="AST">point-equals-point</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="point-in-circle">
+                <output-dir compare="AST">point-in-circle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="point-in-polygon">
+                <output-dir compare="AST">point-in-polygon</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="point-in-rectangle">
+                <output-dir compare="AST">point-in-rectangle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="point-on-line">
+                <output-dir compare="AST">point-on-line</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="polygon_accessor">
+                <output-dir compare="AST">polygon_accessor</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="polygon-intersect-circle">
+                <output-dir compare="AST">polygon-intersect-circle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="polygon-intersect-polygon">
+                <output-dir compare="AST">polygon-intersect-polygon</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="polygon-intersect-rectangle">
+                <output-dir compare="AST">polygon-intersect-rectangle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="rectangle_accessor">
+                <output-dir compare="AST">rectangle_accessor</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="rectangle-intersect-circle">
+                <output-dir compare="AST">rectangle-intersect-circle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="rectangle-intersect-rectangle">
+                <output-dir compare="AST">rectangle-intersect-rectangle</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="spatial">
+            <compilation-unit name="spatial-area">
+                <output-dir compare="AST">spatial-area</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="string">
+        <test-case FilePath="string">
+            <compilation-unit name="codepoint-to-string1">
+                <output-dir compare="AST">codepoint-to-string1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="codepoint-to-string2">
+                <output-dir compare="AST">codepoint-to-string2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="concat_01">
+                <output-dir compare="AST">concat_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="concat_02">
+                <output-dir compare="AST">concat_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="concat_03">
+                <output-dir compare="AST">concat_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="constructor">
+                <output-dir compare="AST">constructor</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="contains_01">
+                <output-dir compare="AST">contains_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="cpttostr01">
+                <output-dir compare="AST">cpttostr01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="cpttostr02">
+                <output-dir compare="AST">cpttostr02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="cpttostr04">
+                <output-dir compare="AST">cpttostr04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="end-with1">
+                <output-dir compare="AST">end-with1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="end-with2">
+                <output-dir compare="AST">end-with2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="end-with3">
+                <output-dir compare="AST">end-with3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="end-with4">
+                <output-dir compare="AST">end-with4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="end-with5">
+                <output-dir compare="AST">end-with5</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="ends-with_01">
+                <output-dir compare="AST">ends-with_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="endwith02">
+                <output-dir compare="AST">endwith02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="endwith03">
+                <output-dir compare="AST">endwith03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="escapes01">
+                <output-dir compare="AST">escapes01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="escapes02">
+                <output-dir compare="AST">escapes02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="length_01">
+                <output-dir compare="AST">length_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="length_02">
+                <output-dir compare="AST">length_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="like_01">
+                <output-dir compare="AST">like_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="like_null">
+                <output-dir compare="AST">like_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="lowercase">
+                <output-dir compare="AST">lowercase</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches02">
+                <output-dir compare="AST">matches02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches03">
+                <output-dir compare="AST">matches03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches04">
+                <output-dir compare="AST">matches04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches05">
+                <output-dir compare="AST">matches05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches06">
+                <output-dir compare="AST">matches06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches1">
+                <output-dir compare="AST">matches1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches11">
+                <output-dir compare="AST">matches11</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches2">
+                <output-dir compare="AST">matches2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches21">
+                <output-dir compare="AST">matches21</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches22">
+                <output-dir compare="AST">matches22</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches23">
+                <output-dir compare="AST">matches23</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matches3">
+                <output-dir compare="AST">matches3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="matchesnull">
+                <output-dir compare="AST">matchesnull</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="replace1">
+                <output-dir compare="AST">replace1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="replace2">
+                <output-dir compare="AST">replace2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="replace21">
+                <output-dir compare="AST">replace21</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="replace22">
+                <output-dir compare="AST">replace22</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="replace3">
+                <output-dir compare="AST">replace3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="start-with1">
+                <output-dir compare="AST">start-with1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="start-with2">
+                <output-dir compare="AST">start-with2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="start-with3">
+                <output-dir compare="AST">start-with3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="start-with4">
+                <output-dir compare="AST">start-with4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="start-with5">
+                <output-dir compare="AST">start-with5</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="starts-with_01">
+                <output-dir compare="AST">starts-with_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="startwith02">
+                <output-dir compare="AST">startwith02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="string">
+          <compilation-unit name="startwith03">
+            <output-dir compare="AST">startwith03</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="string">
+            <compilation-unit name="strconcat01">
+                <output-dir compare="AST">strconcat01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="strconcat02">
+                <output-dir compare="AST">strconcat02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-concat1">
+                <output-dir compare="AST">string-concat1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-equal1">
+                <output-dir compare="AST">string-equal1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-equal2">
+                <output-dir compare="AST">string-equal2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-equal3">
+                <output-dir compare="AST">string-equal3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-equal4">
+                <output-dir compare="AST">string-equal4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-join1">
+                <output-dir compare="AST">string-join1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-to-codepoint">
+                <output-dir compare="AST">string-to-codepoint</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-to-codepoint1">
+                <output-dir compare="AST">string-to-codepoint1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="string-to-codepoint2">
+                <output-dir compare="AST">string-to-codepoint2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="strlen02">
+                <output-dir compare="AST">strlen02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="strlen03">
+                <output-dir compare="AST">strlen03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="strtocpt01">
+                <output-dir compare="AST">strtocpt01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="strtocpt02">
+                <output-dir compare="AST">strtocpt02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="strtocpt03">
+                <output-dir compare="AST">strtocpt03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substr01">
+                <output-dir compare="AST">substr01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substr04">
+                <output-dir compare="AST">substr04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substr05">
+                <output-dir compare="AST">substr05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substr06">
+                <output-dir compare="AST">substr06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-after-1">
+                <output-dir compare="AST">substring-after-1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-after-2">
+                <output-dir compare="AST">substring-after-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-after-3">
+                <output-dir compare="AST">substring-after-3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-after-4">
+                <output-dir compare="AST">substring-after-4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-before-1">
+                <output-dir compare="AST">substring-before-1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-before-2">
+                <output-dir compare="AST">substring-before-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring-before-3">
+                <output-dir compare="AST">substring-before-3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring2-1">
+                <output-dir compare="AST">substring2-1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring2-2">
+                <output-dir compare="AST">substring2-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring2-3">
+                <output-dir compare="AST">substring2-3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring2-4">
+                <output-dir compare="AST">substring2-4</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="substring_01">
+                <output-dir compare="AST">substring_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="toLowerCase02">
+                <output-dir compare="AST">toLowerCase02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="toLowerCase03">
+                <output-dir compare="AST">toLowerCase03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="toLowerCase04">
+                <output-dir compare="AST">toLowerCase04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="string">
+            <compilation-unit name="uppercase">
+                <output-dir compare="AST">uppercase</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="subset-collection">
+        <test-case FilePath="subset-collection">
+            <compilation-unit name="01">
+                <output-dir compare="AST">01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="subset-collection">
+            <compilation-unit name="02">
+                <output-dir compare="AST">02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="subset-collection">
+            <compilation-unit name="03">
+                <output-dir compare="AST">03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="subset-collection">
+            <compilation-unit name="05">
+                <output-dir compare="AST">05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="subset-collection">
+            <compilation-unit name="06">
+                <output-dir compare="AST">06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="subset-collection">
+            <compilation-unit name="07">
+                <output-dir compare="AST">07</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="tokenizers">
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="counthashed-gram-tokens_01">
+                <output-dir compare="AST">counthashed-gram-tokens_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="counthashed-gram-tokens_02">
+                <output-dir compare="AST">counthashed-gram-tokens_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="counthashed-word-tokens_01">
+                <output-dir compare="AST">counthashed-word-tokens_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="gram-tokens_01">
+                <output-dir compare="AST">gram-tokens_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="gram-tokens_02">
+                <output-dir compare="AST">gram-tokens_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="hashed-gram-tokens_01">
+                <output-dir compare="AST">hashed-gram-tokens_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="hashed-gram-tokens_02">
+                <output-dir compare="AST">hashed-gram-tokens_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="hashed-word-tokens_01">
+                <output-dir compare="AST">hashed-word-tokens_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="word-tokens_01">
+                <output-dir compare="AST">word-tokens_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tokenizers">
+            <compilation-unit name="word-tokens_02">
+                <output-dir compare="AST">word-tokens_02</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="tpch">
+        <test-case FilePath="tpch">
+            <compilation-unit name="distinct_by">
+                <output-dir compare="AST">distinct_by</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="group_no_agg">
+                <output-dir compare="AST">group_no_agg</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="nest_aggregate">
+                <output-dir compare="AST">nest_aggregate</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue638">
+                <output-dir compare="AST">query-issue638</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue785">
+                <output-dir compare="AST">query-issue785</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue785-2">
+                <output-dir compare="AST">query-issue785-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue786">
+                <output-dir compare="AST">query-issue786</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue601">
+                <output-dir compare="AST">query-issue601</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q10_returned_item">
+                <output-dir compare="AST">q10_returned_item</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q10_returned_item_int64">
+                <output-dir compare="AST">q10_returned_item_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q11_important_stock">
+                <output-dir compare="AST">q11_important_stock</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q12_shipping">
+                <output-dir compare="AST">q12_shipping</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q13_customer_distribution">
+                <output-dir compare="AST">q13_customer_distribution</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q14_promotion_effect">
+                <output-dir compare="AST">q14_promotion_effect</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q15_top_supplier">
+                <output-dir compare="AST">q15_top_supplier</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q16_parts_supplier_relationship">
+                <output-dir compare="AST">q16_parts_supplier_relationship</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q17_squantity_order_revenue">
+                <output-dir compare="AST">q17_small_quantity_order_revenue</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q17_large_gby_variant">
+                <output-dir compare="AST">q17_large_gby_variant</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q18_large_volume_customer">
+                <output-dir compare="AST">q18_large_volume_customer</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q19_discounted_revenue">
+                <output-dir compare="AST">q19_discounted_revenue</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q01_pricing_summary_report_nt">
+                <output-dir compare="AST">q01_pricing_summary_report_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q20_potential_part_promotion">
+                <output-dir compare="AST">q20_potential_part_promotion</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q21_suppliers_who_kept_orders_waiting">
+                <output-dir compare="AST">q21_suppliers_who_kept_orders_waiting</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q22_global_sales_opportunity">
+                <output-dir compare="AST">q22_global_sales_opportunity</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q02_minimum_cost_supplier">
+                <output-dir compare="AST">q02_minimum_cost_supplier</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q03_shipping_priority_nt">
+                <output-dir compare="AST">q03_shipping_priority_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q04_order_priority">
+                <output-dir compare="AST">q04_order_priority</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q05_local_supplier_volume">
+                <output-dir compare="AST">q05_local_supplier_volume</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q06_forecast_revenue_change">
+                <output-dir compare="AST">q06_forecast_revenue_change</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q07_volume_shipping">
+                <output-dir compare="AST">q07_volume_shipping</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q08_national_market_share">
+                <output-dir compare="AST">q08_national_market_share</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="q09_product_type_profit_nt">
+                <output-dir compare="AST">q09_product_type_profit_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue562">
+                <output-dir compare="AST">query-issue562</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue810">
+                <output-dir compare="AST">query-issue810</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue810-2">
+                <output-dir compare="AST">query-issue810-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue810-3">
+                <output-dir compare="AST">query-issue810-3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue827">
+                <output-dir compare="AST">query-issue827</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch">
+            <compilation-unit name="query-issue827-2">
+                <output-dir compare="AST">query-issue827-2</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="tpch-sql-like">
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="query-issue638">
+                <output-dir compare="AST">query-issue638</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="query-issue785">
+                <output-dir compare="AST">query-issue785</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="query-issue785-2">
+                <output-dir compare="AST">query-issue785-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="query-issue786">
+                <output-dir compare="AST">query-issue786</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="query-issue601">
+                <output-dir compare="AST">query-issue601</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q10_returned_item">
+                <output-dir compare="AST">q10_returned_item</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q10_returned_item_int64">
+                <output-dir compare="AST">q10_returned_item_int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q11_important_stock">
+                <output-dir compare="AST">q11_important_stock</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q12_shipping">
+                <output-dir compare="AST">q12_shipping</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q13_customer_distribution">
+                <output-dir compare="AST">q13_customer_distribution</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q14_promotion_effect">
+                <output-dir compare="AST">q14_promotion_effect</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q15_top_supplier">
+                <output-dir compare="AST">q15_top_supplier</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q16_parts_supplier_relationship">
+                <output-dir compare="AST">q16_parts_supplier_relationship</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q17_small_quantity_order_revenue">
+                <output-dir compare="AST">q17_small_quantity_order_revenue</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q17_large_gby_variant">
+                <output-dir compare="AST">q17_large_gby_variant</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q18_large_volume_customer">
+                <output-dir compare="AST">q18_large_volume_customer</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q19_discounted_revenue">
+                <output-dir compare="AST">q19_discounted_revenue</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q01_pricing_summary_report_nt">
+                <output-dir compare="AST">q01_pricing_summary_report_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q20_potential_part_promotion">
+                <output-dir compare="AST">q20_potential_part_promotion</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q21_suppliers_who_kept_orders_waiting">
+                <output-dir compare="AST">q21_suppliers_who_kept_orders_waiting</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q22_global_sales_opportunity">
+                <output-dir compare="AST">q22_global_sales_opportunity</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q02_minimum_cost_supplier">
+                <output-dir compare="AST">q02_minimum_cost_supplier</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q03_shipping_priority_nt">
+                <output-dir compare="AST">q03_shipping_priority_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q04_order_priority">
+                <output-dir compare="AST">q04_order_priority</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q05_local_supplier_volume">
+                <output-dir compare="AST">q05_local_supplier_volume</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q06_forecast_revenue_change">
+                <output-dir compare="AST">q06_forecast_revenue_change</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q07_volume_shipping">
+                <output-dir compare="AST">q07_volume_shipping</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q08_national_market_share">
+                <output-dir compare="AST">q08_national_market_share</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="tpch-sql-like">
+            <compilation-unit name="q09_product_type_profit_nt">
+                <output-dir compare="AST">q09_product_type_profit_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="writers">
+        <test-case FilePath="writers">
+            <compilation-unit name="print_01">
+                <output-dir compare="AST">print_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--  TODO(madhusudancs): Enable this test when REST API supports serialized output support.
+            <test-case FilePath="writers">
+              <compilation-unit name="serialized_01">
+                <output-dir compare="AST">serialized_01</output-dir>
+              </compilation-unit>
+            </test-case>
+        -->
+    </test-group>
+    <test-group name="cross-dataverse">
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv01">
+                <output-dir compare="AST">cross-dv01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv02">
+                <output-dir compare="AST">cross-dv02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv03">
+                <output-dir compare="AST">cross-dv03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv04">
+                <output-dir compare="AST">cross-dv04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv07">
+                <output-dir compare="AST">cross-dv07</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--NotImplementedException: No binary comparator factory implemented for type RECORD.
+        <test-case FilePath="cross-dataverse">
+          <compilation-unit name="cross-dv08">
+            <output-dir compare="AST">cross-dv08</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv09">
+                <output-dir compare="AST">cross-dv09</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv11">
+                <output-dir compare="AST">cross-dv11</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv12">
+                <output-dir compare="AST">cross-dv12</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv13">
+                <output-dir compare="AST">cross-dv13</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv14">
+                <output-dir compare="AST">cross-dv14</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv15">
+                <output-dir compare="AST">cross-dv15</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv16">
+                <output-dir compare="AST">cross-dv16</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <!--NotImplementedException: No binary comparator factory implemented for type RECORD.
+        <test-case FilePath="cross-dataverse">
+          <compilation-unit name="cross-dv17">
+            <output-dir compare="AST">cross-dv17</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!--NotImplementedException: No binary comparator factory implemented for type RECORD.
+        <test-case FilePath="cross-dataverse">
+          <compilation-unit name="cross-dv18">
+            <output-dir compare="AST">cross-dv18</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv19">
+                <output-dir compare="AST">cross-dv19</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="cross-dv20">
+                <output-dir compare="AST">cross-dv20</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="insert_across_dataverses">
+                <output-dir compare="AST">insert_across_dataverses</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="cross-dataverse">
+            <compilation-unit name="join_across_dataverses">
+                <output-dir compare="AST">join_across_dataverses</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="user-defined-functions">
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue218-2">
+                <output-dir compare="AST">query-issue218-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue218">
+                <output-dir compare="AST">query-issue218</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue201">
+                <output-dir compare="AST">query-issue201</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue172">
+                <output-dir compare="AST">query-issue172</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue455">
+                <output-dir compare="AST">query-issue455</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue489">
+                <output-dir compare="AST">query-issue489</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf01">
+                <output-dir compare="AST">udf01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf02">
+                <output-dir compare="AST">udf02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!-- causes NPE: Issue 200
+        <test-case FilePath="user-defined-functions">
+          <compilation-unit name="udf03">
+            <output-dir compare="AST">udf03</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf04">
+                <output-dir compare="AST">udf04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf05">
+                <output-dir compare="AST">udf05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf06">
+                <output-dir compare="AST">udf06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf07">
+                <output-dir compare="AST">udf07</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf08">
+                <output-dir compare="AST">udf08</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf09">
+                <output-dir compare="AST">udf09</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf10">
+                <output-dir compare="AST">udf10</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf11">
+                <output-dir compare="AST">udf11</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf12">
+                <output-dir compare="AST">udf12</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf13">
+                <output-dir compare="AST">udf13</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf14">
+                <output-dir compare="AST">udf14</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!-- Issue 166
+        <test-case FilePath="user-defined-functions">
+          <compilation-unit name="udf15">
+            <output-dir compare="AST">udf15</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf16">
+                <output-dir compare="AST">udf16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf17">
+                <output-dir compare="AST">udf17</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf18">
+                <output-dir compare="AST">udf18</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf19">
+                <output-dir compare="AST">udf19</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf20">
+                <output-dir compare="AST">udf20</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf21">
+                <output-dir compare="AST">udf21</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf22">
+                <output-dir compare="AST">udf22</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf23">
+                <output-dir compare="AST">udf23</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!-- Issue 195
+        <test-case FilePath="user-defined-functions">
+          <compilation-unit name="udf24">
+            <output-dir compare="AST">udf24</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <!-- Issue 218
+        <test-case FilePath="user-defined-functions">
+          <compilation-unit name="udf25">
+            <output-dir compare="AST">udf25</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf26">
+                <output-dir compare="AST">udf26</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf27">
+                <output-dir compare="AST">udf27</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf28">
+                <output-dir compare="AST">udf28</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf29">
+                <output-dir compare="AST">udf29</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf30">
+                <output-dir compare="AST">udf30</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="f01">
+                <output-dir compare="AST">f01</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="invoke-private-function">
+                <output-dir compare="AST">invoke-private-function</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="load">
+        <test-case FilePath="load">
+            <compilation-unit name="csv_01">
+                <output-dir compare="AST">csv_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_02">
+                <output-dir compare="AST">csv_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_03">
+                <output-dir compare="AST">csv_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_04">
+                <output-dir compare="AST">csv_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_05">
+                <output-dir compare="AST">csv_05</output-dir>
+                <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_06">
+                <output-dir compare="AST">csv_06</output-dir>
+                <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_07">
+                <output-dir compare="AST">csv_07</output-dir>
+                <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_08_header_cr">
+                <output-dir compare="AST">csv_08_header_cr</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_08_header_lf">
+                <output-dir compare="AST">csv_08_header_lf</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="csv_08_header_crlf">
+                <output-dir compare="AST">csv_08_header_crlf</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="issue14_query">
+                <output-dir compare="AST">none</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="issue315_query">
+                <output-dir compare="AST">none</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="issue289_query">
+                <output-dir compare="AST">issue289_query</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="issue650_query">
+                <output-dir compare="AST">none</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="type_promotion_0">
+                <output-dir compare="AST">type_promotion_0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="escapes01">
+                <output-dir compare="AST">escapes01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="escapes02">
+                <output-dir compare="AST">escapes02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="escapes-err-1">
+                <output-dir compare="AST">none</output-dir>
+                <expected-error>org.apache.hyracks.api.exceptions.HyracksException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
+            <compilation-unit name="query-issue244">
+                <output-dir compare="AST">query-issue244</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="duplicate-key-error">
+                <output-dir compare="AST">none</output-dir>
+                <expected-error>org.apache.hyracks.api.exceptions.HyracksException</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="issue610_adm_token_end_collection">
+                <output-dir compare="AST">issue610_adm_token_end_collection</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="adm_binary">
+                <output-dir compare="AST">adm_binary</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="hints">
+        <test-case FilePath="hints">
+            <compilation-unit name="issue_251_dataset_hint_5">
+                <output-dir compare="AST">issue_251_dataset_hint_5</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="hints">
+            <compilation-unit name="issue_251_dataset_hint_6">
+                <output-dir compare="AST">issue_251_dataset_hint_6</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="hints">
+            <compilation-unit name="issue_251_dataset_hint_7">
+                <output-dir compare="AST">issue_251_dataset_hint_7</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="feeds">
+
+        <!--Disable it because of sporadic failures. Raman will re-enable it.
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_01">
+                <output-dir compare="AST">feeds_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_02">
+                <output-dir compare="AST">feeds_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_03">
+                <output-dir compare="AST">feeds_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_04">
+                <output-dir compare="AST">feeds_04</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="feeds">
+          <compilation-unit name="feeds_06">
+            <output-dir compare="AST">feeds_06</output-dir>
+          </compilation-unit>
+        </test-case>
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_07">
+                <output-dir compare="AST">feeds_07</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_08">
+                <output-dir compare="AST">feeds_08</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_09">
+                <output-dir compare="AST">feeds_09</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_10">
+                <output-dir compare="AST">feeds_10</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_11">
+                <output-dir compare="AST">feeds_11</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="feeds">
+            <compilation-unit name="feeds_12">
+                <output-dir compare="AST">feeds_12</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="feeds">
+            <compilation-unit name="issue_230_feeds">
+                <output-dir compare="AST">issue_230_feeds</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="feeds">
+            <compilation-unit name="issue_711_feeds">
+                <output-dir compare="AST">issue_711_feeds</output-dir>
+            </compilation-unit>
+        </test-case>
+        -->
+
+    </test-group>
+    <test-group name="hdfs">
+    	<test-case FilePath="hdfs">
+            <compilation-unit name="hdfs_shortcircuit">
+                <output-dir compare="AST">hdfs_shortcircuit</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="hdfs">
+            <compilation-unit name="issue_245_hdfs">
+                <output-dir compare="AST">issue_245_hdfs</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="hdfs">
+            <compilation-unit name="hdfs_02">
+                <output-dir compare="AST">hdfs_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="hdfs">
+            <compilation-unit name="hdfs_03">
+                <output-dir compare="AST">hdfs_03</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group>
+        <test-case FilePath="big-object">
+            <compilation-unit name="big_object_sort">
+                <output-dir compare="AST">big_object_sort</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="big-object">
+            <compilation-unit name="big_object_groupby">
+                <output-dir compare="AST">big_object_groupby</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="big-object">
+            <compilation-unit name="big_object_groupby-2">
+                <output-dir compare="AST">big_object_groupby-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="big-object">
+            <compilation-unit name="big_object_join">
+                <output-dir compare="AST">big_object_join</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="external-indexing">
+        <test-case FilePath="external-indexing">
+            <compilation-unit name="text-format">
+                <output-dir compare="AST">text-format</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="external-indexing">
+            <compilation-unit name="sequence-format">
+                <output-dir compare="AST">sequence-format</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="external-indexing">
+            <compilation-unit name="rc-format">
+                <output-dir compare="AST">rc-format</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="external-indexing">
+            <compilation-unit name="rtree-index">
+                <output-dir compare="AST">rtree-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="external-indexing">
+            <compilation-unit name="leftouterjoin">
+                <output-dir compare="AST">leftouterjoin</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="external-indexing">
+            <compilation-unit name="leftouterjoin-rtree">
+                <output-dir compare="AST">leftouterjoin-rtree</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="temporal">
+        <test-case FilePath="temporal">
+            <compilation-unit name="overlap_bins_gby_3">
+                <output-dir compare="AST">overlap_bins_gby_3</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="agg_01">
+                <output-dir compare="AST">agg_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="overlap_bins_gby_1">
+                <output-dir compare="AST">overlap_bins_gby_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="duration_functions">
+                <output-dir compare="AST">duration_functions</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="overlap_bins_gby_0">
+                <output-dir compare="AST">overlap_bins_gby_0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="get_overlapping_interval">
+                <output-dir compare="AST">get_overlapping_interval</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="overlap_bins">
+                <output-dir compare="AST">overlap_bins</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="parse_02">
+                <output-dir compare="AST">parse_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="parse_01">
+                <output-dir compare="AST">parse_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="day_of_week_01">
+                <output-dir compare="AST">day_of_week_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="interval_bin">
+                <output-dir compare="AST">interval_bin</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="interval_bin_gby_0">
+                <output-dir compare="AST">interval_bin_gby_0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="interval_bin_gby_1">
+                <output-dir compare="AST">interval_bin_gby_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="accessors">
+                <output-dir compare="AST">accessors</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="accessors_interval">
+                <output-dir compare="AST">accessors_interval</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="accessors_interval_null">
+                <output-dir compare="AST">accessors_interval_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="adjust_timezone">
+                <output-dir compare="AST">adjust_timezone</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="calendar_duration">
+                <output-dir compare="AST">calendar_duration</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="date_functions">
+                <output-dir compare="AST">date_functions</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="datetime_functions">
+                <output-dir compare="AST">datetime_functions</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+       <test-case FilePath="temporal">
+           <compilation-unit name="insert_from_delimited_ds">
+              <output-dir compare="AST">insert_from_delimited_ds</output-dir>
+           </compilation-unit>
+      </test-case>
+        -->
+        <test-case FilePath="temporal">
+            <compilation-unit name="insert_from_ext_ds">
+                <output-dir compare="AST">insert_from_ext_ds</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="insert_from_ext_ds_2">
+                <output-dir compare="AST">insert_from_ext_ds_2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="interval_functions">
+                <output-dir compare="AST">interval_functions</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="time_functions">
+                <output-dir compare="AST">time_functions</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="constructor">
+            <compilation-unit name="interval">
+                <output-dir compare="AST">interval</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temporal">
+            <compilation-unit name="duration_comps">
+                <output-dir compare="AST">duration_comps</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="leftouterjoin">
+        <test-case FilePath="leftouterjoin">
+            <compilation-unit name="query_issue658">
+                <output-dir compare="AST">query_issue658</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="leftouterjoin">
+            <compilation-unit name="query_issue285">
+                <output-dir compare="AST">query_issue285</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="leftouterjoin">
+            <compilation-unit name="query_issue285-2">
+                <output-dir compare="AST">query_issue285-2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="leftouterjoin">
+            <compilation-unit name="query_issue849">
+                <output-dir compare="AST">query_issue849</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="leftouterjoin">
+            <compilation-unit name="query_issue849-2">
+                <output-dir compare="AST">query_issue849-2</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="index-leftouterjoin">
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit name="probe-pidx-with-join-btree-sidx1">
+                <output-dir compare="AST">probe-pidx-with-join-btree-sidx1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit name="probe-pidx-with-join-btree-sidx2">
+                <output-dir compare="AST">probe-pidx-with-join-btree-sidx2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit name="probe-pidx-with-join-rtree-sidx1">
+                <output-dir compare="AST">probe-pidx-with-join-rtree-sidx1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit name="probe-pidx-with-join-rtree-sidx2">
+                <output-dir compare="AST">probe-pidx-with-join-rtree-sidx2</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit name="probe-pidx-with-join-invidx-sidx1">
+                <output-dir compare="AST">probe-pidx-with-join-invidx-sidx1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit name="probe-pidx-with-join-invidx-sidx2">
+                <output-dir compare="AST">probe-pidx-with-join-invidx-sidx2</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="distinct">
+        <test-case FilePath="distinct">
+            <compilation-unit name="query-issue443">
+                <output-dir compare="AST">query-issue443</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="distinct">
+            <compilation-unit name="query-issue443-2">
+                <output-dir compare="AST">query-issue443-2</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="tinysocial">
+        <test-case FilePath="tinysocial">
+            <compilation-unit name="tinysocial-suite">
+                <output-dir compare="AST">tinysocial-suite</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="types">
+        <test-case FilePath="types">
+            <compilation-unit name="record01">
+                <output-dir compare="AST">record01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="type_promotion_0">
+                <output-dir compare="AST">type_promotion_0</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="type_promotion_1">
+                <output-dir compare="AST">type_promotion_1</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="opentype_orderby_01">
+                <output-dir compare="AST">opentype_orderby_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_closedtype_field_01">
+                <output-dir compare="AST">promotion_closedtype_field_vs_closedtype_field_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_closedtype_field_02">
+                <output-dir compare="AST">promotion_closedtype_field_vs_closedtype_field_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_closedtype_field_03">
+                <output-dir compare="AST">promotion_closedtype_field_vs_closedtype_field_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_closedtype_field_04">
+                <output-dir compare="AST">promotion_closedtype_field_vs_closedtype_field_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_closedtype_field_05">
+                <output-dir compare="AST">promotion_closedtype_field_vs_closedtype_field_05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_01">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_02">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_03">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_04">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_05">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_06">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_07">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_07</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_08">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_08</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_09">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_09</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_10">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_10</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_constant_11">
+                <output-dir compare="AST">promotion_closedtype_field_vs_constant_11</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_opentype_field_01">
+                <output-dir compare="AST">promotion_closedtype_field_vs_opentype_field_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_opentype_field_02">
+                <output-dir compare="AST">promotion_closedtype_field_vs_opentype_field_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_opentype_field_03">
+                <output-dir compare="AST">promotion_closedtype_field_vs_opentype_field_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_closedtype_field_vs_opentype_field_04">
+                <output-dir compare="AST">promotion_closedtype_field_vs_opentype_field_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_01">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_02">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_02</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_03">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_03</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_04">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_04</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_05">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_05</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_06">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_06</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_07">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_07</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_constant_08">
+                <output-dir compare="AST">promotion_opentype_field_vs_constant_08</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_opentype_field_01">
+                <output-dir compare="AST">promotion_opentype_field_vs_opentype_field_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="types">
+            <compilation-unit name="promotion_opentype_field_vs_opentype_field_02">
+                <output-dir compare="AST">promotion_opentype_field_vs_opentype_field_02</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="materialization">
+        <test-case FilePath="materialization">
+            <compilation-unit name="assign-reuse">
+                <output-dir compare="AST">assign-reuse</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="filters">
+        <test-case FilePath="filters">
+            <compilation-unit name="equality-predicate">
+                <output-dir compare="AST">equality-predicate</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="load">
+                <output-dir compare="AST">load</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="load-with-secondary-btree">
+                <output-dir compare="AST">load-with-secondary-btree</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="load-with-secondary-inverted-ngram">
+                <output-dir compare="AST">load-with-secondary-inverted-ngram</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="load-with-secondary-inverted-word">
+                <output-dir compare="AST">load-with-secondary-inverted-word</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="load-with-secondary-rtree">
+                <output-dir compare="AST">load-with-secondary-rtree</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="insert">
+                <output-dir compare="AST">insert</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="insert-with-secondary-btree">
+                <output-dir compare="AST">insert-with-secondary-btree</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="insert-with-secondary-inverted-ngram">
+                <output-dir compare="AST">insert-with-secondary-inverted-ngram</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="insert-with-secondary-inverted-word">
+                <output-dir compare="AST">insert-with-secondary-inverted-word</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="insert-with-secondary-rtree">
+                <output-dir compare="AST">insert-with-secondary-rtree</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="filters">
+            <compilation-unit name="nested-filterequality-predicate">
+                <output-dir compare="AST">nested-filter-equality-predicate</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="json">
+        <test-case FilePath="json">
+            <compilation-unit name="int01">
+                <output-dir compare="AST">int01</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="csv">
+        <test-case FilePath="csv">
+            <compilation-unit name="basic-types">
+                <output-dir compare="AST">basic-types</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="binary">
+        <test-case FilePath="binary">
+            <compilation-unit name="parse">
+                <output-dir compare="AST">parse</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="binary">
+            <compilation-unit name="print">
+                <output-dir compare="AST">print</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="binary">
+            <compilation-unit name="concat">
+                <output-dir compare="AST">concat</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="binary">
+            <compilation-unit name="subbinary">
+                <output-dir compare="AST">subbinary</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="binary">
+            <compilation-unit name="find">
+                <output-dir compare="AST">find</output-dir>
+            </compilation-unit>
+        </test-case>
+
+        <test-case FilePath="binary">
+            <compilation-unit name="insert">
+                <output-dir compare="AST">insert</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="binary">
+            <compilation-unit name="equal_join">
+                <output-dir compare="AST">equal_join</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="binary">
+            <compilation-unit name="index_join">
+                <output-dir compare="AST">index_join</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="binary">
+            <compilation-unit name="length">
+                <output-dir compare="AST">length</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+    <test-group name="temp-dataset">
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="delete-from-loaded-dataset">
+                <output-dir compare="AST">delete-from-loaded-dataset</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="delete-from-loaded-dataset-with-index">
+                <output-dir compare="AST">delete-from-loaded-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="drop-empty-secondary-indexes">
+                <output-dir compare="AST">drop-empty-secondary-indexes</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="drop-index">
+                <output-dir compare="AST">drop-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="empty-load-with-index">
+                <output-dir compare="AST">empty-load-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="insert-and-scan-dataset">
+                <output-dir compare="AST">insert-and-scan-dataset</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="q01_pricing_summary_report_nt">
+                <output-dir compare="AST">q01_pricing_summary_report_nt</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="scan-delete-rtree-secondary-index">
+                <output-dir compare="AST">scan-delete-rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="scan-insert-rtree-secondary-index">
+                <output-dir compare="AST">scan-insert-rtree-secondary-index</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="scan-insert-persistent-to-temp">
+                <output-dir compare="AST">scan-insert-persistent-to-temp</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="scan-insert-temp-to-persistent">
+                <output-dir compare="AST">scan-insert-temp-to-persistent</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="temp-dataset">
+            <compilation-unit name="insert-and-scan-dataset-with-index">
+                <output-dir compare="AST">insert-and-scan-dataset-with-index</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
+</test-suite>